--- old/test/hotspot/jtreg/runtime/cds/appcds/RewriteBytecodesTest.java 2019-08-15 10:09:44.117825799 -0700 +++ new/test/hotspot/jtreg/runtime/cds/appcds/RewriteBytecodesTest.java 2019-08-15 10:09:43.599806948 -0700 @@ -24,7 +24,7 @@ /* * @test - * @summary Use ClassLoader.defineClass() to load a class with rewritten bytecode. Make sure + * @summary Use Lookup.defineClass() to load a class with rewritten bytecode. Make sure * the archived class with the same name is not loaded. * @requires vm.cds * @library /test/lib @@ -52,7 +52,6 @@ OutputAnalyzer output = TestCommon.exec(appJar, // command-line arguments ... - "--add-opens=java.base/java.lang=ALL-UNNAMED", use_whitebox_jar, "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", --- old/test/hotspot/jtreg/runtime/cds/appcds/customLoader/LoaderSegregationTest.java 2019-08-15 10:09:45.800887048 -0700 +++ new/test/hotspot/jtreg/runtime/cds/appcds/customLoader/LoaderSegregationTest.java 2019-08-15 10:09:45.292868560 -0700 @@ -63,7 +63,7 @@ String wbJar = JarBuilder.build(true, "WhiteBox", "sun/hotspot/WhiteBox"); String use_whitebox_jar = "-Xbootclasspath/a:" + wbJar; - String appJar = JarBuilder.build("LoaderSegregation_app", "LoaderSegregation", + String appJar = JarBuilder.build("LoaderSegregation_app", "LoaderSegregation", "LoaderSegregation$1", "CustomLoadee", "CustomLoadee2", "CustomLoadee3Child", "CustomInterface2_ia", "OnlyBuiltin", "Util"); @@ -110,8 +110,6 @@ output = TestCommon.exec(TestCommon.concatPaths(appJar, app2Jar), // command-line arguments ... - "--add-opens=java.base/java.lang=ALL-UNNAMED", - "--add-opens=java.base/java.security=ALL-UNNAMED", use_whitebox_jar, "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", --- old/test/hotspot/jtreg/runtime/cds/appcds/customLoader/test-classes/LoaderSegregation.java 2019-08-15 10:09:47.175937087 -0700 +++ new/test/hotspot/jtreg/runtime/cds/appcds/customLoader/test-classes/LoaderSegregation.java 2019-08-15 10:09:46.669918673 -0700 @@ -81,8 +81,25 @@ } { // UNREGISTERED LOADER - URLClassLoader urlClassLoader = new URLClassLoader(urls); - Class c2 = Util.defineClassFromJAR(urlClassLoader, jarFile, ONLY_BUILTIN); + URLClassLoader urlClassLoader = new URLClassLoader(urls) { + protected Class> loadClass(String name, boolean resolve) throws ClassNotFoundException { + synchronized (getClassLoadingLock(name)) { + Class> c = findLoadedClass(name); + if (c == null) { + try { + c = findClass(name); + } catch (ClassNotFoundException e) { + c = getParent().loadClass(name); + } + } + if (resolve) { + resolveClass(c); + } + return c; + } + } + }; + Class> c2 = urlClassLoader.loadClass(ONLY_BUILTIN); if (c2.getClassLoader() != urlClassLoader) { throw new RuntimeException("Error in test"); --- old/test/hotspot/jtreg/runtime/cds/appcds/test-classes/RewriteBytecodes.java 2019-08-15 10:09:48.280977301 -0700 +++ new/test/hotspot/jtreg/runtime/cds/appcds/test-classes/RewriteBytecodes.java 2019-08-15 10:09:47.761958413 -0700 @@ -23,6 +23,7 @@ */ import java.io.File; +import java.lang.invoke.MethodHandles; import sun.hotspot.WhiteBox; public class RewriteBytecodes { @@ -30,7 +31,7 @@ String from = "___xxx___"; String to = "___yyy___"; File clsFile = new File(args[0]); - Class superClass = Util.defineModifiedClass(RewriteBytecodes.class.getClassLoader(), clsFile, from, to); + Class superClass = Util.defineModifiedClass(MethodHandles.lookup(), clsFile, from, to); Child child = new Child(); --- old/test/hotspot/jtreg/runtime/cds/appcds/test-classes/Util.java 2019-08-15 10:09:49.667027741 -0700 +++ new/test/hotspot/jtreg/runtime/cds/appcds/test-classes/Util.java 2019-08-15 10:09:49.159009253 -0700 @@ -23,19 +23,21 @@ */ import java.io.*; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodHandles.Lookup; import java.lang.reflect.*; import java.util.jar.*; public class Util { /** - * Invoke the loader.defineClass() class method to define the class stored in clsFile, + * Define the class as stored in clsFile with the provided lookup instance, * with the following modification: *