author | iklam |
Fri, 29 Mar 2019 08:42:32 -0700 | |
changeset 54340 | 2221f042556d |
parent 53636 | 962ed57b29c9 |
permissions | -rw-r--r-- |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
1 |
/* |
53636
962ed57b29c9
8218029: [TESTBUG] Use -Djava.class.path= to specify empty -cp in CDS tests
iklam
parents:
51990
diff
changeset
|
2 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
4 |
* |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
8 |
* |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
13 |
* accompanied this code). |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
14 |
* |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
18 |
* |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
21 |
* questions. |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
22 |
* |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
23 |
*/ |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
24 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
25 |
/** |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
26 |
* @test |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
27 |
* @requires vm.cds |
51675 | 28 |
* @library /test/lib /test/hotspot/jtreg/runtime/appcds |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
29 |
* @modules jdk.compiler |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
30 |
* jdk.jartool/sun.tools.jar |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
31 |
* jdk.jlink |
51990
6003e034cdd8
8209946: [TESTBUG] CDS tests should use "@run driver"
iklam
parents:
51675
diff
changeset
|
32 |
* @run driver ModulePathAndCP |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
33 |
* @summary 2 sets of tests: one with only --module-path in the command line; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
34 |
* another with both -cp and --module-path in the command line. |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
35 |
*/ |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
36 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
37 |
import java.io.File; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
38 |
import java.nio.file.Files; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
39 |
import java.nio.file.Path; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
40 |
import java.nio.file.Paths; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
41 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
42 |
import jdk.test.lib.process.OutputAnalyzer; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
43 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
44 |
public class ModulePathAndCP { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
45 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
46 |
private static final Path USER_DIR = Paths.get(System.getProperty("user.dir")); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
47 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
48 |
private static final String TEST_SRC = System.getProperty("test.src"); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
49 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
50 |
private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
51 |
private static final Path MODS_DIR = Paths.get("mods"); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
52 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
53 |
// the module name of the test module |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
54 |
private static final String MAIN_MODULE = "com.greetings"; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
55 |
private static final String APP_MODULE = "org.astro"; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
56 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
57 |
// the module main class |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
58 |
private static final String MAIN_CLASS = "com.greetings.Main"; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
59 |
private static final String APP_CLASS = "org.astro.World"; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
60 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
61 |
private static Path moduleDir = null; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
62 |
private static Path moduleDir2 = null; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
63 |
private static Path subJar = null; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
64 |
private static Path mainJar = null; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
65 |
private static Path destJar = null; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
66 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
67 |
public static void buildTestModule() throws Exception { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
68 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
69 |
// javac -d mods/$TESTMODULE src/$TESTMODULE/** |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
70 |
JarBuilder.compileModule(SRC_DIR.resolve(APP_MODULE), |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
71 |
MODS_DIR.resolve(APP_MODULE), |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
72 |
null); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
73 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
74 |
// javac -d mods/$TESTMODULE --module-path MOD_DIR src/$TESTMODULE/** |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
75 |
JarBuilder.compileModule(SRC_DIR.resolve(MAIN_MODULE), |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
76 |
MODS_DIR.resolve(MAIN_MODULE), |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
77 |
MODS_DIR.toString()); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
78 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
79 |
moduleDir = Files.createTempDirectory(USER_DIR, "mlib"); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
80 |
moduleDir2 = Files.createTempDirectory(USER_DIR, "mlib2"); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
81 |
subJar = moduleDir.resolve(APP_MODULE + ".jar"); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
82 |
destJar = moduleDir2.resolve(APP_MODULE + ".jar"); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
83 |
String classes = MODS_DIR.resolve(APP_MODULE).toString(); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
84 |
JarBuilder.createModularJar(subJar.toString(), classes, null); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
85 |
Files.copy(subJar, destJar); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
86 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
87 |
mainJar = moduleDir.resolve(MAIN_MODULE + ".jar"); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
88 |
Path mainJar2 = moduleDir2.resolve(MAIN_MODULE + ".jar"); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
89 |
classes = MODS_DIR.resolve(MAIN_MODULE).toString(); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
90 |
JarBuilder.createModularJar(mainJar.toString(), classes, MAIN_CLASS); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
91 |
Files.copy(mainJar, mainJar2); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
92 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
93 |
} |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
94 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
95 |
public static void main(String... args) throws Exception { |
54340
2221f042556d
8221351: Crash in KlassFactory::check_shared_class_file_load_hook
iklam
parents:
53636
diff
changeset
|
96 |
run(); |
2221f042556d
8221351: Crash in KlassFactory::check_shared_class_file_load_hook
iklam
parents:
53636
diff
changeset
|
97 |
} |
2221f042556d
8221351: Crash in KlassFactory::check_shared_class_file_load_hook
iklam
parents:
53636
diff
changeset
|
98 |
|
2221f042556d
8221351: Crash in KlassFactory::check_shared_class_file_load_hook
iklam
parents:
53636
diff
changeset
|
99 |
public static void run(String... extra_runtime_args) throws Exception { |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
100 |
// compile the modules and create the modular jar files |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
101 |
buildTestModule(); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
102 |
String appClasses[] = {MAIN_CLASS, APP_CLASS}; |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
103 |
// create an archive with the classes in the modules built in the |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
104 |
// previous step |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
105 |
OutputAnalyzer output = TestCommon.createArchive( |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
106 |
null, appClasses, |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
107 |
"--module-path", moduleDir.toString(), |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
108 |
"-m", MAIN_MODULE); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
109 |
TestCommon.checkDump(output); |
53636
962ed57b29c9
8218029: [TESTBUG] Use -Djava.class.path= to specify empty -cp in CDS tests
iklam
parents:
51990
diff
changeset
|
110 |
String prefix[] = {"-Djava.class.path=", "-Xlog:class+load=trace"}; |
54340
2221f042556d
8221351: Crash in KlassFactory::check_shared_class_file_load_hook
iklam
parents:
53636
diff
changeset
|
111 |
prefix = TestCommon.concat(prefix, extra_runtime_args); |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
112 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
113 |
// run with the archive with the --module-path the same as the one during |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
114 |
// dump time. The classes should be loaded from the archive. |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
115 |
TestCommon.runWithModules(prefix, |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
116 |
null, // --upgrade-module-path |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
117 |
moduleDir.toString(), // --module-path |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
118 |
MAIN_MODULE) // -m |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
119 |
.assertNormalExit(out -> { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
120 |
out.shouldContain("[class,load] com.greetings.Main source: shared objects file") |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
121 |
.shouldContain("[class,load] org.astro.World source: shared objects file"); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
122 |
}); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
123 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
124 |
// run with the archive with the --module-path different from the one during |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
125 |
// dump time. The classes should be loaded from the jar files. |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
126 |
TestCommon.runWithModules(prefix, |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
127 |
null, // --upgrade-module-path |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
128 |
moduleDir2.toString(), // --module-path |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
129 |
MAIN_MODULE) // -m |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
130 |
.assertNormalExit(out -> { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
131 |
out.shouldMatch(".class.load. com.greetings.Main source:.*com.greetings.jar") |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
132 |
.shouldMatch(".class.load. org.astro.World source:.*org.astro.jar"); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
133 |
}); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
134 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
135 |
// create an archive with modular jar files in both -cp and --module-path |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
136 |
String jars = subJar.toString() + System.getProperty("path.separator") + |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
137 |
mainJar.toString(); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
138 |
output = TestCommon.createArchive( jars, appClasses, |
49942
f4310c01104d
8202130: [TESTBUG] Some appcds regression test cases fail with "Error: VM option 'PrintSystemDictionaryAtExit' is notproduct and is available only in debug version of VM"
ccheung
parents:
49739
diff
changeset
|
139 |
"-Xlog:class+load=trace", |
49739
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
140 |
"--module-path", moduleDir.toString(), |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
141 |
"-m", MAIN_MODULE); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
142 |
TestCommon.checkDump(output); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
143 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
144 |
// run with archive with the main class name specified before |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
145 |
// the module name with the -m option. Since the -m option was specified |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
146 |
// during dump time, the classes in the jar files after the -cp won't be |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
147 |
// archived. Therefore, the classes won't be loaded from the archive but |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
148 |
// will be loaded from the jar files. |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
149 |
TestCommon.run("-Xlog:class+load=trace", |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
150 |
"-cp", jars, |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
151 |
"--module-path", moduleDir.toString(), |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
152 |
MAIN_CLASS, "-m", MAIN_MODULE) |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
153 |
.assertNormalExit(out -> { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
154 |
out.shouldMatch(".class.load. com.greetings.Main source:.*com.greetings.jar") |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
155 |
.shouldMatch(".class.load. org.astro.World source:.*org.astro.jar"); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
156 |
}); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
157 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
158 |
// similar to the above case but without the main class name. The classes |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
159 |
// should be loaded from the archive. |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
160 |
TestCommon.run("-Xlog:class+load=trace", |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
161 |
"-cp", jars, |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
162 |
"--module-path", moduleDir.toString(), |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
163 |
"-m", MAIN_MODULE) |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
164 |
.assertNormalExit( |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
165 |
"[class,load] com.greetings.Main source: shared objects file", |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
166 |
"[class,load] org.astro.World source: shared objects file"); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
167 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
168 |
// create an archive with two modular jars in the --module-path |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
169 |
output = TestCommon.createArchive( |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
170 |
null, appClasses, |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
171 |
"--module-path", jars, |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
172 |
"-m", MAIN_MODULE); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
173 |
TestCommon.checkDump(output); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
174 |
|
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
175 |
// run with the above archive but with the modular jar containing the |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
176 |
// org.astro module in a different location. |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
177 |
// The org.astro.World class should be loaded from the jar. |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
178 |
// The Main class should still be loaded from the archive. |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
179 |
jars = destJar.toString() + System.getProperty("path.separator") + |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
180 |
mainJar.toString(); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
181 |
TestCommon.runWithModules(prefix, |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
182 |
null, // --upgrade-module-path |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
183 |
jars, // --module-path |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
184 |
MAIN_MODULE) // -m |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
185 |
.assertNormalExit(out -> { |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
186 |
out.shouldContain("[class,load] com.greetings.Main source: shared objects file") |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
187 |
.shouldMatch(".class.load. org.astro.World source:.*org.astro.jar"); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
188 |
}); |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
189 |
} |
00805b129186
8194812: Extend class-data sharing to support the module path
ccheung
parents:
diff
changeset
|
190 |
} |