67 private void setup() throws Throwable { |
67 private void setup() throws Throwable { |
68 Path src = TEST_SRC.resolve("src"); |
68 Path src = TEST_SRC.resolve("src"); |
69 for (String name : modules) { |
69 for (String name : modules) { |
70 assertTrue(CompilerUtils.compile(src.resolve(name), |
70 assertTrue(CompilerUtils.compile(src.resolve(name), |
71 MODS_DIR, |
71 MODS_DIR, |
72 "-modulesourcepath", src.toString())); |
72 "--module-source-path", src.toString())); |
73 } |
73 } |
74 |
74 |
75 // compile patched source |
75 // compile patched source |
76 assertTrue(CompilerUtils.compile(PATCH_SRC_DIR.resolve(JAVA_BASE), |
76 assertTrue(CompilerUtils.compile(PATCH_SRC_DIR.resolve(JAVA_BASE), |
77 PATCH_DIR.resolve(JAVA_BASE), |
77 PATCH_DIR.resolve(JAVA_BASE), |
91 Path patchedJavaBase = PATCH_DIR.resolve(JAVA_BASE); |
91 Path patchedJavaBase = PATCH_DIR.resolve(JAVA_BASE); |
92 Path patchedM2 = PATCH_DIR.resolve("m2"); |
92 Path patchedM2 = PATCH_DIR.resolve("m2"); |
93 |
93 |
94 Path home = Paths.get(JAVA_HOME); |
94 Path home = Paths.get(JAVA_HOME); |
95 runTest(home, |
95 runTest(home, |
96 "-mp", MODS_DIR.toString(), |
96 "--module-path", MODS_DIR.toString(), |
97 "-m", "m1/p1.Main", "1"); |
97 "-m", "m1/p1.Main", "1"); |
98 runTest(home, |
98 runTest(home, |
99 "-Xpatch:java.base=" + patchedJavaBase.toString(), |
99 "--patch-module", "java.base=" + patchedJavaBase, |
100 "-mp", MODS_DIR.toString(), |
100 "--module-path", MODS_DIR.toString(), |
101 "-m", "m1/p1.Main", "1"); |
101 "-m", "m1/p1.Main", "1"); |
102 |
102 |
103 runTest(home, |
103 runTest(home, |
104 "-Xpatch:m2=" + patchedM2.toString(), |
104 "--patch-module", "m2=" + patchedM2.toString(), |
105 "-mp", MODS_DIR.toString(), |
105 "--module-path", MODS_DIR.toString(), |
106 "-m", "m1/p1.Main", "2"); |
106 "-m", "m1/p1.Main", "2"); |
107 } |
107 } |
108 |
108 |
109 @Test |
109 @Test |
110 public void testImage() throws Throwable { |
110 public void testImage() throws Throwable { |
115 Path patchedM2 = PATCH_DIR.resolve("m2"); |
115 Path patchedM2 = PATCH_DIR.resolve("m2"); |
116 |
116 |
117 runTest(IMAGE, |
117 runTest(IMAGE, |
118 "-m", "m1/p1.Main", "1"); |
118 "-m", "m1/p1.Main", "1"); |
119 runTest(IMAGE, |
119 runTest(IMAGE, |
120 "-Xpatch:java.base=" + patchedJavaBase.toString(), |
120 "--patch-module", "java.base=" + patchedJavaBase, |
121 "-m", "m1/p1.Main", "1"); |
121 "-m", "m1/p1.Main", "1"); |
122 runTest(IMAGE, |
122 runTest(IMAGE, |
123 "-Xpatch:m2=" + patchedM2.toString(), |
123 "--patch-module", "m2=" + patchedM2.toString(), |
124 "-m", "m1/p1.Main", "2"); |
124 "-m", "m1/p1.Main", "2"); |
125 } |
125 } |
126 |
126 |
127 @Test |
127 @Test |
128 public void upgradeTiedModule() throws Throwable { |
128 public void upgradeTiedModule() throws Throwable { |
136 "--file=" + m1.toString(), |
136 "--file=" + m1.toString(), |
137 "-C", MODS_DIR.resolve("m1").toString(), "."); |
137 "-C", MODS_DIR.resolve("m1").toString(), "."); |
138 |
138 |
139 // Fail to upgrade m1.jar with mismatched hash |
139 // Fail to upgrade m1.jar with mismatched hash |
140 runTestWithExitCode(getJava(IMAGE), |
140 runTestWithExitCode(getJava(IMAGE), |
141 "-upgrademodulepath", m1.toString(), |
141 "--upgrade-module-path", m1.toString(), |
142 "-m", "m1/p1.Main"); |
142 "-m", "m1/p1.Main"); |
143 |
143 |
144 runTestWithExitCode(getJava(IMAGE), |
144 runTestWithExitCode(getJava(IMAGE), |
145 "-Xpatch:java.base=" + PATCH_DIR.resolve(JAVA_BASE).toString(), |
145 "--patch-module", "java.base=" + PATCH_DIR.resolve(JAVA_BASE), |
146 "-upgrademodulepath", m1.toString(), |
146 "--upgrade-module-path", m1.toString(), |
147 "-m", "m1/p1.Main", "1"); |
147 "-m", "m1/p1.Main", "1"); |
148 } |
148 } |
149 |
149 |
150 private void runTestWithExitCode(String... options) throws Throwable { |
150 private void runTestWithExitCode(String... options) throws Throwable { |
151 assertTrue(executeCommand(options) |
151 assertTrue(executeCommand(options) |
183 "--file=" + m1.toString(), |
183 "--file=" + m1.toString(), |
184 "-C", MODS_DIR.resolve("m1").toString(), "."); |
184 "-C", MODS_DIR.resolve("m1").toString(), "."); |
185 |
185 |
186 jar("--create", |
186 jar("--create", |
187 "--file=" + m2.toString(), |
187 "--file=" + m2.toString(), |
188 "--modulepath", JARS_DIR.toString(), |
188 "--module-path", JARS_DIR.toString(), |
189 "--hash-modules", "m1", |
189 "--hash-modules", "m1", |
190 "-C", MODS_DIR.resolve("m2").toString(), "."); |
190 "-C", MODS_DIR.resolve("m2").toString(), "."); |
191 |
191 |
192 |
192 |
193 String mpath = JARS_DIR.toString() + File.pathSeparator + JMODS.toString(); |
193 String mpath = JARS_DIR.toString() + File.pathSeparator + JMODS.toString(); |
194 execTool("jlink", "--modulepath", mpath, |
194 execTool("jlink", "--module-path", mpath, |
195 "--addmods", "m1", |
195 "--add-modules", "m1", |
196 "--output", IMAGE.toString()); |
196 "--output", IMAGE.toString()); |
197 } |
197 } |
198 |
198 |
199 static void jar(String... args) throws Throwable { |
199 static void jar(String... args) throws Throwable { |
200 execTool("jar", args); |
200 execTool("jar", args); |
214 |
214 |
215 assertTrue(exitValue == 0); |
215 assertTrue(exitValue == 0); |
216 } |
216 } |
217 |
217 |
218 static String getJava(Path image) { |
218 static String getJava(Path image) { |
219 boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("win"); |
219 boolean isWindows = System.getProperty("os.name").startsWith("Windows"); |
220 Path java = image.resolve("bin").resolve(isWindows ? "java.exe" : "java"); |
220 Path java = image.resolve("bin").resolve(isWindows ? "java.exe" : "java"); |
221 if (Files.notExists(java)) |
221 if (Files.notExists(java)) |
222 throw new RuntimeException(java + " not found"); |
222 throw new RuntimeException(java + " not found"); |
223 return java.toAbsolutePath().toString(); |
223 return java.toAbsolutePath().toString(); |
224 } |
224 } |