Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK-8304163: Move jdk.internal.module.ModuleInfoWriter to the test library #13085

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -21,7 +21,7 @@
* questions.
*/

import jdk.internal.module.ModuleInfoWriter;
import jdk.test.lib.util.ModuleInfoWriter;

import java.io.File;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -35,13 +35,17 @@
* @test
* @bug 8221730
* @summary Test of diagnostic command VM.version (tests all DCMD executors)
* @library /test/lib
* /vmTestbase
* @modules java.base/jdk.internal.misc
* @modules java.base/jdk.internal.classfile
* java.base/jdk.internal.classfile.attribute
* java.base/jdk.internal.classfile.constantpool
* java.base/jdk.internal.classfile.java.lang.constant
* java.base/jdk.internal.misc
* java.base/jdk.internal.module
* java.compiler
* java.management
* jdk.internal.jvmstat/sun.jvmstat.monitor
* @library /test/lib
* /vmTestbase
* @run testng/othervm -XX:+UsePerfData VMVersionTest
*/
public class VMVersionTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -26,9 +26,14 @@
* @bug 8168423
* @summary Different types of ClassLoader running with(out) SecurityManager and
* (in)valid security policy file.
* @modules java.base/jdk.internal.classfile
* java.base/jdk.internal.classfile.attribute
* java.base/jdk.internal.classfile.constantpool
* java.base/jdk.internal.classfile.java.lang.constant
* java.base/jdk.internal.module
* @library /test/lib
* @modules java.base/jdk.internal.module
* @build jdk.test.lib.util.JarUtils
* jdk.test.lib.util.ModuleInfoWriter
* @build TestClassLoader TestClient
* @run main ClassLoaderTest -noPolicy
* @run main ClassLoaderTest -validPolicy
Expand All @@ -48,9 +53,9 @@
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import jdk.internal.module.ModuleInfoWriter;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.util.JarUtils;
import jdk.test.lib.util.ModuleInfoWriter;

public class ClassLoaderTest {

Expand Down
10 changes: 8 additions & 2 deletions test/jdk/java/lang/ModuleTests/AnnotationsTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -36,14 +36,14 @@
import java.util.List;
import java.util.Set;

import jdk.internal.module.ModuleInfoWriter;
import jdk.internal.org.objectweb.asm.AnnotationVisitor;
import jdk.internal.org.objectweb.asm.Attribute;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassVisitor;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.Opcodes;
import jdk.internal.org.objectweb.asm.commons.ModuleTargetAttribute;
import jdk.test.lib.util.ModuleInfoWriter;

import org.testng.annotations.Test;
import static org.testng.Assert.*;
Expand All @@ -52,7 +52,13 @@
* @test
* @modules java.base/jdk.internal.org.objectweb.asm
* java.base/jdk.internal.org.objectweb.asm.commons
* java.base/jdk.internal.classfile
* java.base/jdk.internal.classfile.attribute
* java.base/jdk.internal.classfile.constantpool
* java.base/jdk.internal.classfile.java.lang.constant
* java.base/jdk.internal.module
* @library /test/lib
* @build jdk.test.lib.util.ModuleInfoWriter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to build library classes explicitly. I think @library /test/lib it enough.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @lmesnik, on the contrary, these build directives are recommended (and based on some of the issues we have encountered, are in fact necessary). The jtreg documentation has this to say https://openjdk.org/jtreg/tag-spec.html:

In general, classes in library directories are not automatically compiled as part of a compilation command explicitly naming the source files containing those classes. A test that relies upon library classes should contain appropriate @build directives to ensure that the classes will be compiled. It is strongly recommended that tests do not rely on the use of implicit compilation by the Java compiler. Such an approach is generally fragile, and may lead to incomplete recompilation when a test or library code has been modified.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicit compilation is exactly the reason of adding @build

* @run testng AnnotationsTest
* @summary Basic test of annotations on modules
*/
Expand Down
12 changes: 9 additions & 3 deletions test/jdk/java/lang/module/ClassFileVersionsTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,7 +23,13 @@

/**
* @test
* @modules java.base/jdk.internal.module
* @modules java.base/jdk.internal.classfile
* java.base/jdk.internal.classfile.attribute
* java.base/jdk.internal.classfile.constantpool
* java.base/jdk.internal.classfile.java.lang.constant
* java.base/jdk.internal.module
* @library /test/lib
* @build jdk.test.lib.util.ModuleInfoWriter
* @run testng ClassFileVersionsTest
* @summary Test parsing of module-info.class with different class file versions
*/
Expand All @@ -36,7 +42,7 @@

import static java.lang.module.ModuleDescriptor.Requires.Modifier.*;

import jdk.internal.module.ModuleInfoWriter;
import jdk.test.lib.util.ModuleInfoWriter;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
Expand Down
11 changes: 8 additions & 3 deletions test/jdk/java/lang/module/ConfigurationTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,10 +23,15 @@

/**
* @test
* @library /test/lib
* @modules java.base/jdk.internal.access
* java.base/jdk.internal.classfile
* java.base/jdk.internal.classfile.attribute
* java.base/jdk.internal.classfile.constantpool
* java.base/jdk.internal.classfile.java.lang.constant
* java.base/jdk.internal.module
* @library /test/lib
* @build ConfigurationTest
* jdk.test.lib.util.ModuleInfoWriter
* jdk.test.lib.util.ModuleUtils
* @run testng ConfigurationTest
* @summary Basic tests for java.lang.module.Configuration
Expand All @@ -47,10 +52,10 @@
import java.util.List;
import java.util.Set;

import jdk.test.lib.util.ModuleInfoWriter;
import jdk.test.lib.util.ModuleUtils;

import jdk.internal.access.SharedSecrets;
import jdk.internal.module.ModuleInfoWriter;
import jdk.internal.module.ModuleTarget;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
Expand Down
9 changes: 6 additions & 3 deletions test/jdk/java/lang/module/ModuleDescriptorTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,10 +25,13 @@
* @test
* @bug 8142968 8158456 8298875
* @modules java.base/jdk.internal.access
* java.base/jdk.internal.module
* java.base/jdk.internal.classfile
* java.base/jdk.internal.classfile.attribute
* java.base/jdk.internal.classfile.constantpool
* java.base/jdk.internal.classfile.java.lang.constant
* java.base/jdk.internal.module
* @library /test/lib
* @build jdk.test.lib.util.ModuleInfoWriter
* @run testng ModuleDescriptorTest
* @summary Basic test for java.lang.module.ModuleDescriptor and its builder
*/
Expand Down Expand Up @@ -64,7 +67,7 @@
import jdk.internal.classfile.attribute.ModuleAttribute;
import jdk.internal.classfile.java.lang.constant.PackageDesc;
import jdk.internal.classfile.java.lang.constant.ModuleDesc;
import jdk.internal.module.ModuleInfoWriter;
import jdk.test.lib.util.ModuleInfoWriter;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
Expand Down
13 changes: 9 additions & 4 deletions test/jdk/java/lang/module/ModuleFinderTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,8 +23,13 @@

/**
* @test
* @modules java.base/jdk.internal.module
* @build ModuleFinderTest
* @modules java.base/jdk.internal.classfile
* java.base/jdk.internal.classfile.attribute
* java.base/jdk.internal.classfile.constantpool
* java.base/jdk.internal.classfile.java.lang.constant
* java.base/jdk.internal.module
* @library /test/lib
* @build ModuleFinderTest jdk.test.lib.util.ModuleInfoWriter
* @run testng ModuleFinderTest
* @summary Basic tests for java.lang.module.ModuleFinder
*/
Expand All @@ -45,7 +50,7 @@
import java.util.jar.JarOutputStream;
import java.util.stream.Collectors;

import jdk.internal.module.ModuleInfoWriter;
import jdk.test.lib.util.ModuleInfoWriter;

import org.testng.annotations.Test;
import static org.testng.Assert.*;
Expand Down
11 changes: 9 additions & 2 deletions test/jdk/java/lang/module/ModuleNamesTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -24,7 +24,13 @@
/**
* @test
* @modules java.base/jdk.internal.access
* java.base/jdk.internal.classfile
* java.base/jdk.internal.classfile.attribute
* java.base/jdk.internal.classfile.constantpool
* java.base/jdk.internal.classfile.java.lang.constant
* java.base/jdk.internal.module
* @library /test/lib
* @build jdk.test.lib.util.ModuleInfoWriter
* @run testng ModuleNamesTest
* @summary Basic test of reading a module-info.class with module names that
* are legal in class files but not legal in the Java Language
Expand All @@ -42,7 +48,8 @@
import java.util.Set;

import jdk.internal.access.SharedSecrets;
import jdk.internal.module.ModuleInfoWriter;

import jdk.test.lib.util.ModuleInfoWriter;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
Expand Down
14 changes: 10 additions & 4 deletions test/jdk/java/lang/module/MultiReleaseJarTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,9 +23,15 @@

/**
* @test
* @modules java.base/jdk.internal.classfile
* java.base/jdk.internal.classfile.attribute
* java.base/jdk.internal.classfile.constantpool
* java.base/jdk.internal.classfile.java.lang.constant
* java.base/jdk.internal.module
* @library /test/lib
* @modules java.base/jdk.internal.module
* @build MultiReleaseJarTest jdk.test.lib.util.JarUtils
* @build MultiReleaseJarTest
* jdk.test.lib.util.JarUtils
* jdk.test.lib.util.ModuleInfoWriter
* @run testng MultiReleaseJarTest
* @run testng/othervm -Djdk.util.jar.enableMultiRelease=false MultiReleaseJarTest
* @summary Basic test of modular JARs as multi-release JARs
Expand Down Expand Up @@ -54,7 +60,7 @@
import java.util.jar.Attributes;
import java.util.jar.Manifest;

import jdk.internal.module.ModuleInfoWriter;
import jdk.test.lib.util.ModuleInfoWriter;
import jdk.test.lib.util.JarUtils;

import org.testng.annotations.Test;
Expand Down
15 changes: 10 additions & 5 deletions test/jdk/java/security/Provider/SecurityProviderModularTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -38,19 +38,24 @@
import java.io.OutputStream;
import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleDescriptor.Builder;
import jdk.internal.module.ModuleInfoWriter;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.util.JarUtils;

import jdk.test.lib.util.ModuleInfoWriter;

/*
* @test
* @bug 8130360 8183310
* @summary Test security provider in different combination of modular option
* defined with(out) service description.
* @modules java.base/jdk.internal.classfile
* java.base/jdk.internal.classfile.attribute
* java.base/jdk.internal.classfile.constantpool
* java.base/jdk.internal.classfile.java.lang.constant
* java.base/jdk.internal.module
* @library /test/lib
* @modules java.base/jdk.internal.module
* @build jdk.test.lib.util.JarUtils TestProvider TestClient
* @build jdk.test.lib.util.JarUtils
* jdk.test.lib.util.ModuleInfoWriter
* TestProvider TestClient
* @run main SecurityProviderModularTest CL true
* @run main SecurityProviderModularTest CL false
* @run main SecurityProviderModularTest SL true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -33,19 +33,23 @@
import java.io.OutputStream;
import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleDescriptor.Builder;
import jdk.internal.module.ModuleInfoWriter;
import java.util.stream.Stream;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.util.JarUtils;
import jdk.test.lib.util.ModuleInfoWriter;

/*
* @test
* @bug 8078813 8183310
* @summary Test custom JAAS login module with all possible modular option.
* @modules java.base/jdk.internal.classfile
* java.base/jdk.internal.classfile.attribute
* java.base/jdk.internal.classfile.constantpool
* java.base/jdk.internal.classfile.java.lang.constant
* java.base/jdk.internal.module
* @library /test/lib
* @modules java.base/jdk.internal.module
* @build jdk.test.lib.util.JarUtils
* @build jdk.test.lib.util.JarUtils jdk.test.lib.util.ModuleInfoWriter
* @build TestLoginModule JaasClient
* @run main JaasModularClientTest false
* @run main JaasModularClientTest true
Expand Down
Loading