equal
deleted
inserted
replaced
24 |
24 |
25 /** |
25 /** |
26 * @test |
26 * @test |
27 * @requires vm.cds |
27 * @requires vm.cds |
28 * @modules java.base/jdk.internal.misc |
28 * @modules java.base/jdk.internal.misc |
|
29 * jdk.jartool/sun.tools.jar |
29 * @library ../.. |
30 * @library ../.. |
30 * @library /test/lib |
31 * @library /test/lib |
|
32 * @compile ../../test-classes/Hello.java |
31 * @run driver OverrideTests |
33 * @run driver OverrideTests |
32 * @summary AppCDS tests for overriding archived classes with -p and --upgrade-module-path |
34 * @summary AppCDS tests for overriding archived classes with -p and --upgrade-module-path |
33 */ |
35 */ |
34 |
36 |
35 /* |
37 /* |
63 |
65 |
64 public class OverrideTests { |
66 public class OverrideTests { |
65 private static final String TEST_SRC = System.getProperty("test.src"); |
67 private static final String TEST_SRC = System.getProperty("test.src"); |
66 private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); |
68 private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); |
67 private static final Path MODS_DIR = Paths.get("mods"); |
69 private static final Path MODS_DIR = Paths.get("mods"); |
68 |
70 private static String appJar; |
69 // the module that is upgraded |
71 // the module that is upgraded |
70 private static final String[] UPGRADED_MODULES = {"jdk.compiler", "java.net.http"}; |
72 private static final String[] UPGRADED_MODULES = {"jdk.compiler", "java.net.http"}; |
71 private static final Path[] UPGRADEDMODS_DIR = {Paths.get("upgradedmod1"), Paths.get("upgradedmod2")}; |
73 private static final Path[] UPGRADEDMODS_DIR = {Paths.get("upgradedmod1"), Paths.get("upgradedmod2")}; |
72 |
74 |
73 // the test module |
75 // the test module |
80 private static final String[] ARCHIVE_CLASSES = {APP_ARCHIVE_CLASS, PLATFORM_ARCHIVE_CLASS}; |
82 private static final String[] ARCHIVE_CLASSES = {APP_ARCHIVE_CLASS, PLATFORM_ARCHIVE_CLASS}; |
81 private static String testArchiveName; |
83 private static String testArchiveName; |
82 |
84 |
83 |
85 |
84 public static void main(String[] args) throws Exception { |
86 public static void main(String[] args) throws Exception { |
|
87 appJar = JarBuilder.getOrCreateHelloJar(); |
85 OverrideTests tests = new OverrideTests(); |
88 OverrideTests tests = new OverrideTests(); |
86 tests.compileModulesAndDumpArchive(); |
89 tests.compileModulesAndDumpArchive(); |
87 tests.testAppClassOverriding(); |
90 tests.testAppClassOverriding(); |
88 tests.testPlatformClassOverriding(); |
91 tests.testPlatformClassOverriding(); |
89 } |
92 } |
109 System.getProperty("path.separator") + UPGRADEDMODS_DIR[1].toString() |
112 System.getProperty("path.separator") + UPGRADEDMODS_DIR[1].toString() |
110 ); |
113 ); |
111 Asserts.assertTrue(compiled, TEST_MODULE + " did not compile"); |
114 Asserts.assertTrue(compiled, TEST_MODULE + " did not compile"); |
112 |
115 |
113 // dump the archive with jdk.compiler and java.net.http classes in the class list |
116 // dump the archive with jdk.compiler and java.net.http classes in the class list |
114 OutputAnalyzer output = TestCommon.dump(null /* appJar*/, TestCommon.list(ARCHIVE_CLASSES)); |
117 OutputAnalyzer output = TestCommon.dump(appJar, TestCommon.list(ARCHIVE_CLASSES)); |
115 TestCommon.checkDump(output); |
118 TestCommon.checkDump(output); |
116 // Make sure all the classes where successfully archived. |
119 // Make sure all the classes where successfully archived. |
117 for (String archiveClass : ARCHIVE_CLASSES) { |
120 for (String archiveClass : ARCHIVE_CLASSES) { |
118 output.shouldNotContain("Preload Warning: Cannot find " + archiveClass); |
121 output.shouldNotContain("Preload Warning: Cannot find " + archiveClass); |
119 } |
122 } |
158 OutputAnalyzer output; |
161 OutputAnalyzer output; |
159 boolean isAppLoader = loaderName.equals("app"); |
162 boolean isAppLoader = loaderName.equals("app"); |
160 int upgradeModIdx = isAppLoader ? 0 : 1; |
163 int upgradeModIdx = isAppLoader ? 0 : 1; |
161 String expectedException = "java.lang.module.FindException: Unable to compute the hash"; |
164 String expectedException = "java.lang.module.FindException: Unable to compute the hash"; |
162 String prefix[] = new String[3]; |
165 String prefix[] = new String[3]; |
163 prefix[0] = "-Djava.class.path="; |
166 prefix[0] = "-Djava.class.path=" + appJar; |
164 prefix[1] = "--add-modules"; |
167 prefix[1] = "--add-modules"; |
165 prefix[2] = "java.net.http"; |
168 prefix[2] = "java.net.http"; |
166 |
169 |
167 // Run the test with --upgrade-module-path set to alternate location of archiveClass |
170 // Run the test with --upgrade-module-path set to alternate location of archiveClass |
168 // The alternate version of archiveClass SHOULD be found. |
171 // The alternate version of archiveClass SHOULD be found. |