From 3eda19b5259569f4fbfa9fbf47bd1119de97e35b Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Fri, 17 Mar 2023 14:56:18 -0700 Subject: [PATCH 1/2] JDK-8304163: Move jdk.internal.module.ModuleInfoWriter to the test library --- .../framework/TestProcessModuleLauncher.java | 4 ++-- .../dcmd/framework/VMVersionTest.java | 8 ++++++-- .../securityManager/ClassLoaderTest.java | 11 ++++++++--- .../java/lang/ModuleTests/AnnotationsTest.java | 10 ++++++++-- .../java/lang/module/ClassFileVersionsTest.java | 12 +++++++++--- test/jdk/java/lang/module/ConfigurationTest.java | 9 +++++++-- .../java/lang/module/ModuleDescriptorTest.java | 9 ++++++--- test/jdk/java/lang/module/ModuleFinderTest.java | 13 +++++++++---- test/jdk/java/lang/module/ModuleNamesTest.java | 11 +++++++++-- .../java/lang/module/MultiReleaseJarTest.java | 14 ++++++++++---- .../Provider/SecurityProviderModularTest.java | 15 ++++++++++----- .../login/modules/JaasModularClientTest.java | 12 ++++++++---- .../modules/JaasModularDefaultHandlerTest.java | 12 ++++++++---- .../jdk/modules/incubator/ServiceBinding.java | 13 ++++++++----- test/jdk/sun/tools/jcmd/TestProcessHelper.java | 10 ++++++++-- test/jdk/tools/jlink/JLinkNegativeTest.java | 16 +++++++++------- .../lib/jdk/test/lib/util}/ModuleInfoWriter.java | 11 ++++++----- 17 files changed, 131 insertions(+), 59 deletions(-) rename {src/java.base/share/classes/jdk/internal/module => test/lib/jdk/test/lib/util}/ModuleInfoWriter.java (97%) diff --git a/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessModuleLauncher.java b/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessModuleLauncher.java index ac9125ab7ae35..8dc526a48bb7c 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessModuleLauncher.java +++ b/test/hotspot/jtreg/serviceability/dcmd/framework/TestProcessModuleLauncher.java @@ -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 @@ -21,7 +21,7 @@ * questions. */ -import jdk.internal.module.ModuleInfoWriter; +import jdk.test.lib.util.ModuleInfoWriter; import java.io.File; import java.io.IOException; diff --git a/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java b/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java index ae25a54ddf535..44424be0fc170 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java @@ -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 @@ -37,7 +37,11 @@ * @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 diff --git a/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java b/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java index efb243bde979e..9ab4f8d150deb 100644 --- a/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java +++ b/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java @@ -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 @@ -27,8 +27,13 @@ * @summary Different types of ClassLoader running with(out) SecurityManager and * (in)valid security policy file. * @library /test/lib - * @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 * @build jdk.test.lib.util.JarUtils + * jdk.test.lib.util.ModuleInfoWriter * @build TestClassLoader TestClient * @run main ClassLoaderTest -noPolicy * @run main ClassLoaderTest -validPolicy @@ -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 { diff --git a/test/jdk/java/lang/ModuleTests/AnnotationsTest.java b/test/jdk/java/lang/ModuleTests/AnnotationsTest.java index 7bb0d3e60566c..ff8b6927feba5 100644 --- a/test/jdk/java/lang/ModuleTests/AnnotationsTest.java +++ b/test/jdk/java/lang/ModuleTests/AnnotationsTest.java @@ -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 @@ -36,7 +36,6 @@ 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; @@ -44,6 +43,7 @@ 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.*; @@ -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 * @run testng AnnotationsTest * @summary Basic test of annotations on modules */ diff --git a/test/jdk/java/lang/module/ClassFileVersionsTest.java b/test/jdk/java/lang/module/ClassFileVersionsTest.java index 9d723662b24ee..03623da122ef7 100644 --- a/test/jdk/java/lang/module/ClassFileVersionsTest.java +++ b/test/jdk/java/lang/module/ClassFileVersionsTest.java @@ -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 @@ -23,7 +23,13 @@ /** * @test - * @modules java.base/jdk.internal.module + * @library /test/lib + * @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 + * @build jdk.test.lib.util.ModuleInfoWriter * @run testng ClassFileVersionsTest * @summary Test parsing of module-info.class with different class file versions */ @@ -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; diff --git a/test/jdk/java/lang/module/ConfigurationTest.java b/test/jdk/java/lang/module/ConfigurationTest.java index aa9f47a201911..eaca2eb882a2e 100644 --- a/test/jdk/java/lang/module/ConfigurationTest.java +++ b/test/jdk/java/lang/module/ConfigurationTest.java @@ -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 @@ -25,8 +25,13 @@ * @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 * @build ConfigurationTest + * jdk.test.lib.util.ModuleInfoWriter * jdk.test.lib.util.ModuleUtils * @run testng ConfigurationTest * @summary Basic tests for java.lang.module.Configuration @@ -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; diff --git a/test/jdk/java/lang/module/ModuleDescriptorTest.java b/test/jdk/java/lang/module/ModuleDescriptorTest.java index e495443a83e72..ae452190c1d9c 100644 --- a/test/jdk/java/lang/module/ModuleDescriptorTest.java +++ b/test/jdk/java/lang/module/ModuleDescriptorTest.java @@ -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 @@ -24,11 +24,14 @@ /** * @test * @bug 8142968 8158456 8298875 + * @library /test/lib * @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 + * @build jdk.test.lib.util.ModuleInfoWriter * @run testng ModuleDescriptorTest * @summary Basic test for java.lang.module.ModuleDescriptor and its builder */ @@ -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.*; diff --git a/test/jdk/java/lang/module/ModuleFinderTest.java b/test/jdk/java/lang/module/ModuleFinderTest.java index 79feee5694b7d..312d9d653ffdf 100644 --- a/test/jdk/java/lang/module/ModuleFinderTest.java +++ b/test/jdk/java/lang/module/ModuleFinderTest.java @@ -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 @@ -23,8 +23,13 @@ /** * @test - * @modules java.base/jdk.internal.module - * @build ModuleFinderTest + * @library /test/lib + * @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 + * @build ModuleFinderTest jdk.test.lib.util.ModuleInfoWriter * @run testng ModuleFinderTest * @summary Basic tests for java.lang.module.ModuleFinder */ @@ -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.*; diff --git a/test/jdk/java/lang/module/ModuleNamesTest.java b/test/jdk/java/lang/module/ModuleNamesTest.java index 141f453b4f1a0..6ed364baa7398 100644 --- a/test/jdk/java/lang/module/ModuleNamesTest.java +++ b/test/jdk/java/lang/module/ModuleNamesTest.java @@ -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 @@ -23,8 +23,14 @@ /** * @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 + * @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 @@ -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; diff --git a/test/jdk/java/lang/module/MultiReleaseJarTest.java b/test/jdk/java/lang/module/MultiReleaseJarTest.java index 76a9b8f201df9..d149bca532b8f 100644 --- a/test/jdk/java/lang/module/MultiReleaseJarTest.java +++ b/test/jdk/java/lang/module/MultiReleaseJarTest.java @@ -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 @@ -24,8 +24,14 @@ /** * @test * @library /test/lib - * @modules java.base/jdk.internal.module - * @build MultiReleaseJarTest jdk.test.lib.util.JarUtils + * @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 + * @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 @@ -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; diff --git a/test/jdk/java/security/Provider/SecurityProviderModularTest.java b/test/jdk/java/security/Provider/SecurityProviderModularTest.java index 560331e3ada94..ef33ec82ebe38 100644 --- a/test/jdk/java/security/Provider/SecurityProviderModularTest.java +++ b/test/jdk/java/security/Provider/SecurityProviderModularTest.java @@ -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 @@ -38,10 +38,9 @@ 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 @@ -49,8 +48,14 @@ * @summary Test security provider in different combination of modular option * defined with(out) service description. * @library /test/lib - * @modules java.base/jdk.internal.module - * @build jdk.test.lib.util.JarUtils TestProvider TestClient + * @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 + * @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 diff --git a/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java b/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java index 987c0e2e66adf..2925fc4ded305 100644 --- a/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java +++ b/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java @@ -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 @@ -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. * @library /test/lib - * @modules java.base/jdk.internal.module - * @build jdk.test.lib.util.JarUtils + * @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 + * @build jdk.test.lib.util.JarUtils jdk.test.lib.util.ModuleInfoWriter * @build TestLoginModule JaasClient * @run main JaasModularClientTest false * @run main JaasModularClientTest true diff --git a/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java b/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java index 5752c4e3c5d7d..1b627b813e1a8 100644 --- a/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java +++ b/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java @@ -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 @@ -32,19 +32,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 8151654 8183310 * @summary Test default callback handler with all possible modular option. * @library /test/lib - * @modules java.base/jdk.internal.module - * @build jdk.test.lib.util.JarUtils + * @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 + * @build jdk.test.lib.util.JarUtils jdk.test.lib.util.ModuleInfoWriter * @build TestCallbackHandler TestLoginModule JaasClientWithDefaultHandler * @run main JaasModularDefaultHandlerTest */ diff --git a/test/jdk/jdk/modules/incubator/ServiceBinding.java b/test/jdk/jdk/modules/incubator/ServiceBinding.java index 3cb4a903e3e3c..647f2229231f5 100644 --- a/test/jdk/jdk/modules/incubator/ServiceBinding.java +++ b/test/jdk/jdk/modules/incubator/ServiceBinding.java @@ -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 @@ -24,9 +24,13 @@ /** * @test * @bug 8233922 - * @modules java.base/jdk.internal.module * @library /test/lib - * @build ServiceBinding TestBootLayer + * @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 + * @build ServiceBinding TestBootLayer jdk.test.lib.util.ModuleInfoWriter * @run testng ServiceBinding * @summary Test service binding with incubator modules */ @@ -43,17 +47,16 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; -import java.util.stream.Stream; import static java.lang.module.ModuleDescriptor.newModule; -import jdk.internal.module.ModuleInfoWriter; import jdk.internal.module.ModuleResolution; import org.testng.annotations.Test; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.util.ModuleInfoWriter; @Test public class ServiceBinding { diff --git a/test/jdk/sun/tools/jcmd/TestProcessHelper.java b/test/jdk/sun/tools/jcmd/TestProcessHelper.java index 7cd12d0fe3a32..5d62697fe8364 100644 --- a/test/jdk/sun/tools/jcmd/TestProcessHelper.java +++ b/test/jdk/sun/tools/jcmd/TestProcessHelper.java @@ -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 @@ -41,10 +41,10 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import jdk.internal.module.ModuleInfoWriter; import jdk.test.lib.JDKToolFinder; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.util.JarUtils; +import jdk.test.lib.util.ModuleInfoWriter; /* * @test @@ -55,8 +55,14 @@ * @requires os.family == "linux" * @library /test/lib * @modules jdk.jcmd/sun.tools.common:+open + * 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 * @build test.TestProcess + * jdk.test.lib.util.JarUtils + * jdk.test.lib.util.ModuleInfoWriter * @run main/othervm TestProcessHelper */ public class TestProcessHelper { diff --git a/test/jdk/tools/jlink/JLinkNegativeTest.java b/test/jdk/tools/jlink/JLinkNegativeTest.java index 6c7a50e6c4306..dc5737704d538 100644 --- a/test/jdk/tools/jlink/JLinkNegativeTest.java +++ b/test/jdk/tools/jlink/JLinkNegativeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 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 @@ -28,15 +28,19 @@ * @bug 8174718 * @bug 8189671 * @author Andrei Eremeev - * @library ../lib - * @modules java.base/jdk.internal.jimage + * @library /test/lib ../lib + * @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.jimage * java.base/jdk.internal.module * jdk.jdeps/com.sun.tools.classfile * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage * jdk.compiler - * @build tests.* + * @build tests.* jdk.test.lib.util.ModuleInfoWriter * @run testng JLinkNegativeTest */ @@ -48,17 +52,15 @@ import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Set; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; -import jdk.internal.module.ModuleInfoWriter; +import jdk.test.lib.util.ModuleInfoWriter; import org.testng.SkipException; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java b/test/lib/jdk/test/lib/util/ModuleInfoWriter.java similarity index 97% rename from src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java rename to test/lib/jdk/test/lib/util/ModuleInfoWriter.java index 1530fa9221cd3..8aae7654fb768 100644 --- a/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java +++ b/test/lib/jdk/test/lib/util/ModuleInfoWriter.java @@ -1,12 +1,10 @@ /* - * Copyright (c) 2015, 2020, 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 * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -22,7 +20,8 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.module; + +package jdk.test.lib.util; import java.io.IOException; import java.io.OutputStream; @@ -42,6 +41,8 @@ import jdk.internal.classfile.attribute.ModuleRequireInfo; import jdk.internal.classfile.attribute.ModuleTargetAttribute; import jdk.internal.classfile.constantpool.ModuleEntry; +import jdk.internal.module.ModuleResolution; +import jdk.internal.module.ModuleTarget; /** * Utility class to write a ModuleDescriptor as a module-info.class. From 6b7611ad6a3a81d61e28f721c9f67422f124667c Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Sat, 18 Mar 2023 12:06:45 -0700 Subject: [PATCH 2/2] move @library after @modules per the recommended ordering --- .../jtreg/serviceability/dcmd/framework/VMVersionTest.java | 4 ++-- .../lang/ClassLoader/securityManager/ClassLoaderTest.java | 2 +- test/jdk/java/lang/module/ClassFileVersionsTest.java | 2 +- test/jdk/java/lang/module/ConfigurationTest.java | 2 +- test/jdk/java/lang/module/ModuleDescriptorTest.java | 2 +- test/jdk/java/lang/module/ModuleFinderTest.java | 2 +- test/jdk/java/lang/module/ModuleNamesTest.java | 2 +- test/jdk/java/lang/module/MultiReleaseJarTest.java | 2 +- .../java/security/Provider/SecurityProviderModularTest.java | 2 +- .../security/auth/login/modules/JaasModularClientTest.java | 2 +- .../auth/login/modules/JaasModularDefaultHandlerTest.java | 2 +- test/jdk/jdk/modules/incubator/ServiceBinding.java | 2 +- test/jdk/sun/tools/jcmd/TestProcessHelper.java | 2 +- test/jdk/tools/jlink/JLinkNegativeTest.java | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java b/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java index 44424be0fc170..432a326e35d0d 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java @@ -35,8 +35,6 @@ * @test * @bug 8221730 * @summary Test of diagnostic command VM.version (tests all DCMD executors) - * @library /test/lib - * /vmTestbase * @modules java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool @@ -46,6 +44,8 @@ * java.compiler * java.management * jdk.internal.jvmstat/sun.jvmstat.monitor + * @library /test/lib + * /vmTestbase * @run testng/othervm -XX:+UsePerfData VMVersionTest */ public class VMVersionTest { diff --git a/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java b/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java index 9ab4f8d150deb..6268ad7ac5283 100644 --- a/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java +++ b/test/jdk/java/lang/ClassLoader/securityManager/ClassLoaderTest.java @@ -26,12 +26,12 @@ * @bug 8168423 * @summary Different types of ClassLoader running with(out) SecurityManager and * (in)valid security policy file. - * @library /test/lib * @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.JarUtils * jdk.test.lib.util.ModuleInfoWriter * @build TestClassLoader TestClient diff --git a/test/jdk/java/lang/module/ClassFileVersionsTest.java b/test/jdk/java/lang/module/ClassFileVersionsTest.java index 03623da122ef7..39f6f33f8daa8 100644 --- a/test/jdk/java/lang/module/ClassFileVersionsTest.java +++ b/test/jdk/java/lang/module/ClassFileVersionsTest.java @@ -23,12 +23,12 @@ /** * @test - * @library /test/lib * @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 diff --git a/test/jdk/java/lang/module/ConfigurationTest.java b/test/jdk/java/lang/module/ConfigurationTest.java index eaca2eb882a2e..f15b53a12b351 100644 --- a/test/jdk/java/lang/module/ConfigurationTest.java +++ b/test/jdk/java/lang/module/ConfigurationTest.java @@ -23,13 +23,13 @@ /** * @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 diff --git a/test/jdk/java/lang/module/ModuleDescriptorTest.java b/test/jdk/java/lang/module/ModuleDescriptorTest.java index ae452190c1d9c..6ff5bb5443cb5 100644 --- a/test/jdk/java/lang/module/ModuleDescriptorTest.java +++ b/test/jdk/java/lang/module/ModuleDescriptorTest.java @@ -24,13 +24,13 @@ /** * @test * @bug 8142968 8158456 8298875 - * @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 jdk.test.lib.util.ModuleInfoWriter * @run testng ModuleDescriptorTest * @summary Basic test for java.lang.module.ModuleDescriptor and its builder diff --git a/test/jdk/java/lang/module/ModuleFinderTest.java b/test/jdk/java/lang/module/ModuleFinderTest.java index 312d9d653ffdf..61db59b970c44 100644 --- a/test/jdk/java/lang/module/ModuleFinderTest.java +++ b/test/jdk/java/lang/module/ModuleFinderTest.java @@ -23,12 +23,12 @@ /** * @test - * @library /test/lib * @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 diff --git a/test/jdk/java/lang/module/ModuleNamesTest.java b/test/jdk/java/lang/module/ModuleNamesTest.java index 6ed364baa7398..8b69bf856aea0 100644 --- a/test/jdk/java/lang/module/ModuleNamesTest.java +++ b/test/jdk/java/lang/module/ModuleNamesTest.java @@ -23,13 +23,13 @@ /** * @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 jdk.test.lib.util.ModuleInfoWriter * @run testng ModuleNamesTest * @summary Basic test of reading a module-info.class with module names that diff --git a/test/jdk/java/lang/module/MultiReleaseJarTest.java b/test/jdk/java/lang/module/MultiReleaseJarTest.java index d149bca532b8f..db93cb17a7783 100644 --- a/test/jdk/java/lang/module/MultiReleaseJarTest.java +++ b/test/jdk/java/lang/module/MultiReleaseJarTest.java @@ -23,12 +23,12 @@ /** * @test - * @library /test/lib * @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 MultiReleaseJarTest * jdk.test.lib.util.JarUtils * jdk.test.lib.util.ModuleInfoWriter diff --git a/test/jdk/java/security/Provider/SecurityProviderModularTest.java b/test/jdk/java/security/Provider/SecurityProviderModularTest.java index ef33ec82ebe38..d1133e95cc11c 100644 --- a/test/jdk/java/security/Provider/SecurityProviderModularTest.java +++ b/test/jdk/java/security/Provider/SecurityProviderModularTest.java @@ -47,12 +47,12 @@ * @bug 8130360 8183310 * @summary Test security provider in different combination of modular option * defined with(out) service description. - * @library /test/lib * @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.JarUtils * jdk.test.lib.util.ModuleInfoWriter * TestProvider TestClient diff --git a/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java b/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java index 2925fc4ded305..28b03aeb8aae6 100644 --- a/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java +++ b/test/jdk/javax/security/auth/login/modules/JaasModularClientTest.java @@ -43,12 +43,12 @@ * @test * @bug 8078813 8183310 * @summary Test custom JAAS login module with all possible modular option. - * @library /test/lib * @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.JarUtils jdk.test.lib.util.ModuleInfoWriter * @build TestLoginModule JaasClient * @run main JaasModularClientTest false diff --git a/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java b/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java index 1b627b813e1a8..6e74558b905ba 100644 --- a/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java +++ b/test/jdk/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java @@ -42,12 +42,12 @@ * @test * @bug 8151654 8183310 * @summary Test default callback handler with all possible modular option. - * @library /test/lib * @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.JarUtils jdk.test.lib.util.ModuleInfoWriter * @build TestCallbackHandler TestLoginModule JaasClientWithDefaultHandler * @run main JaasModularDefaultHandlerTest diff --git a/test/jdk/jdk/modules/incubator/ServiceBinding.java b/test/jdk/jdk/modules/incubator/ServiceBinding.java index 647f2229231f5..81d7aa2a2c1c0 100644 --- a/test/jdk/jdk/modules/incubator/ServiceBinding.java +++ b/test/jdk/jdk/modules/incubator/ServiceBinding.java @@ -24,12 +24,12 @@ /** * @test * @bug 8233922 - * @library /test/lib * @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 ServiceBinding TestBootLayer jdk.test.lib.util.ModuleInfoWriter * @run testng ServiceBinding * @summary Test service binding with incubator modules diff --git a/test/jdk/sun/tools/jcmd/TestProcessHelper.java b/test/jdk/sun/tools/jcmd/TestProcessHelper.java index 5d62697fe8364..7864378f94e39 100644 --- a/test/jdk/sun/tools/jcmd/TestProcessHelper.java +++ b/test/jdk/sun/tools/jcmd/TestProcessHelper.java @@ -53,13 +53,13 @@ * and checks that sun.tools.ProcessHelper.getMainClass(pid) method returns a correct main class. return a . * * @requires os.family == "linux" - * @library /test/lib * @modules jdk.jcmd/sun.tools.common:+open * 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 test.TestProcess * jdk.test.lib.util.JarUtils * jdk.test.lib.util.ModuleInfoWriter diff --git a/test/jdk/tools/jlink/JLinkNegativeTest.java b/test/jdk/tools/jlink/JLinkNegativeTest.java index dc5737704d538..03db28bf6a8b4 100644 --- a/test/jdk/tools/jlink/JLinkNegativeTest.java +++ b/test/jdk/tools/jlink/JLinkNegativeTest.java @@ -28,7 +28,6 @@ * @bug 8174718 * @bug 8189671 * @author Andrei Eremeev - * @library /test/lib ../lib * @modules java.base/jdk.internal.classfile * java.base/jdk.internal.classfile.attribute * java.base/jdk.internal.classfile.constantpool @@ -40,6 +39,7 @@ * jdk.jlink/jdk.tools.jmod * jdk.jlink/jdk.tools.jimage * jdk.compiler + * @library /test/lib ../lib * @build tests.* jdk.test.lib.util.ModuleInfoWriter * @run testng JLinkNegativeTest */