49 |
50 |
50 private static final String TEST_SRC = System.getProperty("test.src"); |
51 private static final String TEST_SRC = System.getProperty("test.src"); |
51 |
52 |
52 private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); |
53 private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); |
53 private static final Path MODS_DIR = Paths.get("mods"); |
54 private static final Path MODS_DIR = Paths.get("mods"); |
|
55 private static final Path UPGRADE_MODS_DIRS = Paths.get("upgrademods"); |
54 |
56 |
55 // test module m1 that uses Unsafe |
57 // test module m1 that uses Unsafe |
56 private static final String TEST1_MODULE = "m1"; |
58 private static final String TEST1_MODULE = "m1"; |
57 private static final String TEST1_MAIN_CLASS = "jdk.test1.Main"; |
59 private static final String TEST1_MAIN_CLASS = "jdk.test1.Main"; |
58 |
60 |
59 |
61 // test module m2 uses java.compiler internals |
|
62 private static final String TEST2_MODULE = "m2"; |
|
63 private static final String TEST2_MAIN_CLASS = "jdk.test2.Main"; |
60 |
64 |
61 // test module m3 uses m4 internals |
65 // test module m3 uses m4 internals |
62 private static final String TEST3_MODULE = "m3"; |
66 private static final String TEST3_MODULE = "m3"; |
63 private static final String TEST3_MAIN_CLASS = "jdk.test3.Main"; |
67 private static final String TEST3_MAIN_CLASS = "jdk.test3.Main"; |
64 private static final String TEST4_MODULE = "m4"; |
68 private static final String TEST4_MODULE = "m4"; |
72 SRC_DIR.resolve(TEST1_MODULE), |
76 SRC_DIR.resolve(TEST1_MODULE), |
73 MODS_DIR.resolve(TEST1_MODULE), |
77 MODS_DIR.resolve(TEST1_MODULE), |
74 "--add-exports", "java.base/jdk.internal.misc=m1"); |
78 "--add-exports", "java.base/jdk.internal.misc=m1"); |
75 assertTrue(compiled, "module " + TEST1_MODULE + " did not compile"); |
79 assertTrue(compiled, "module " + TEST1_MODULE + " did not compile"); |
76 |
80 |
77 |
81 // javac -d upgrademods/java.compiler src/java.compiler/** |
|
82 compiled = CompilerUtils.compile( |
|
83 SRC_DIR.resolve("java.compiler"), |
|
84 UPGRADE_MODS_DIRS.resolve("java.compiler")); |
|
85 assertTrue(compiled, "module java.compiler did not compile"); |
|
86 |
|
87 // javac --upgrade-module-path upgrademods -d mods/m2 src/m2/** |
|
88 compiled = CompilerUtils.compile( |
|
89 SRC_DIR.resolve(TEST2_MODULE), |
|
90 MODS_DIR.resolve(TEST2_MODULE), |
|
91 "--upgrade-module-path", UPGRADE_MODS_DIRS.toString(), |
|
92 "--add-exports", "java.compiler/javax.tools.internal=m2"); |
|
93 assertTrue(compiled, "module " + TEST2_MODULE + " did not compile"); |
78 |
94 |
79 // javac -d mods/m3 src/m3/** |
95 // javac -d mods/m3 src/m3/** |
80 compiled = CompilerUtils.compile( |
96 compiled = CompilerUtils.compile( |
81 SRC_DIR.resolve(TEST3_MODULE), |
97 SRC_DIR.resolve(TEST3_MODULE), |
82 MODS_DIR.resolve(TEST3_MODULE)); |
98 MODS_DIR.resolve(TEST3_MODULE)); |
144 .getExitValue(); |
160 .getExitValue(); |
145 |
161 |
146 assertTrue(exitValue == 0); |
162 assertTrue(exitValue == 0); |
147 } |
163 } |
148 |
164 |
149 |
165 /** |
|
166 * Test --add-exports with upgraded module |
|
167 */ |
|
168 public void testWithUpgradedModule() throws Exception { |
|
169 |
|
170 // java --add-exports java.compiler/javax.tools.internal=m2 |
|
171 // --upgrade-module-path upgrademods --module-path mods -m ... |
|
172 String mid = TEST2_MODULE + "/" + TEST2_MAIN_CLASS; |
|
173 int exitValue = executeTestJava( |
|
174 "--add-exports", "java.compiler/javax.tools.internal=m2", |
|
175 "--upgrade-module-path", UPGRADE_MODS_DIRS.toString(), |
|
176 "--module-path", MODS_DIR.toString(), |
|
177 "-m", mid) |
|
178 .outputTo(System.out) |
|
179 .errorTo(System.out) |
|
180 .getExitValue(); |
|
181 |
|
182 assertTrue(exitValue == 0); |
|
183 } |
150 |
184 |
151 /** |
185 /** |
152 * Test --add-exports with module that is added to the set of root modules |
186 * Test --add-exports with module that is added to the set of root modules |
153 * with --add-modules. |
187 * with --add-modules. |
154 */ |
188 */ |