author | jjg |
Tue, 22 Nov 2016 15:57:32 -0800 | |
changeset 42269 | 24a766b7c106 |
parent 41938 | 8e66bf10fcec |
child 42822 | a84956e7ee4d |
permissions | -rw-r--r-- |
36526 | 1 |
/* |
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
* @test |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
26 |
* @summary Test the --add-reads option |
36526 | 27 |
* @library /tools/lib |
28 |
* @modules jdk.compiler/com.sun.tools.javac.api |
|
29 |
* jdk.compiler/com.sun.tools.javac.main |
|
30 |
* jdk.jdeps/com.sun.tools.javap |
|
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
31 |
* java.desktop |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
32 |
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask toolbox.JavapTask ModuleTestBase |
36526 | 33 |
* @run main AddReadsTest |
34 |
*/ |
|
35 |
||
36 |
import java.nio.file.Files; |
|
37 |
import java.nio.file.Path; |
|
38 |
import java.util.Set; |
|
39 |
||
40 |
import javax.annotation.processing.AbstractProcessor; |
|
41 |
import javax.annotation.processing.RoundEnvironment; |
|
42 |
import javax.annotation.processing.SupportedAnnotationTypes; |
|
43 |
import javax.lang.model.SourceVersion; |
|
44 |
import javax.lang.model.element.ModuleElement; |
|
45 |
import javax.lang.model.element.ModuleElement.RequiresDirective; |
|
46 |
import javax.lang.model.element.TypeElement; |
|
47 |
import javax.lang.model.util.ElementFilter; |
|
48 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
49 |
import toolbox.JarTask; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
50 |
import toolbox.JavacTask; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
51 |
import toolbox.JavapTask; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
52 |
import toolbox.Task; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
53 |
|
36526 | 54 |
public class AddReadsTest extends ModuleTestBase { |
55 |
||
56 |
public static void main(String... args) throws Exception { |
|
57 |
new AddReadsTest().runTests(); |
|
58 |
} |
|
59 |
||
60 |
@Test |
|
37758 | 61 |
public void testAddReads(Path base) throws Exception { |
36526 | 62 |
Path src = base.resolve("src"); |
63 |
Path src_m1 = src.resolve("m1"); |
|
64 |
tb.writeJavaFiles(src_m1, |
|
65 |
"module m1 { exports api; }", |
|
66 |
"package api; public class Api { }"); |
|
67 |
Path src_m2 = src.resolve("m2"); |
|
68 |
tb.writeJavaFiles(src_m2, |
|
69 |
"module m2 { }", |
|
70 |
"package test; public class Test extends api.Api { }"); |
|
71 |
Path classes = base.resolve("classes"); |
|
72 |
tb.createDirectories(classes); |
|
73 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
74 |
String log = new JavacTask(tb) |
36526 | 75 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
76 |
"--module-source-path", src.toString()) |
36526 | 77 |
.outdir(classes) |
78 |
.files(findJavaFiles(src)) |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
79 |
.run(Task.Expect.FAIL) |
36526 | 80 |
.writeAll() |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
81 |
.getOutput(Task.OutputKind.DIRECT); |
36526 | 82 |
|
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
83 |
checkOutputContains(log, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
84 |
"Test.java:1:44: compiler.err.not.def.access.package.cant.access: api.Api, api"); |
36526 | 85 |
|
86 |
//test add dependencies: |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
87 |
new JavacTask(tb) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
88 |
.options("--add-reads", "m2=m1", |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
89 |
"--module-source-path", src.toString(), |
36526 | 90 |
"-processor", VerifyRequires.class.getName()) |
91 |
.outdir(classes) |
|
92 |
.files(findJavaFiles(src)) |
|
93 |
.run() |
|
94 |
.writeAll(); |
|
95 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
96 |
String decompiled = new JavapTask(tb) |
36526 | 97 |
.options("-verbose", classes.resolve("m2").resolve("module-info.class").toString()) |
98 |
.run() |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
99 |
.getOutput(Task.OutputKind.DIRECT); |
36526 | 100 |
|
101 |
if (decompiled.contains("m1")) { |
|
102 |
throw new Exception("Incorrectly refers to m1 module."); |
|
103 |
} |
|
104 |
||
105 |
//cyclic dependencies OK when created through addReads: |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
106 |
new JavacTask(tb) |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
107 |
.options("--add-reads", "m2=m1", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
108 |
"--add-reads", "m1=m2", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
109 |
"--module-source-path", src.toString()) |
36526 | 110 |
.outdir(classes) |
111 |
.files(findJavaFiles(src)) |
|
112 |
.run() |
|
113 |
.writeAll(); |
|
114 |
||
115 |
tb.writeJavaFiles(src_m2, |
|
116 |
"module m2 { requires m1; }"); |
|
117 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
118 |
new JavacTask(tb) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
119 |
.options("--add-reads", "m1=m2", |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
120 |
"--module-source-path", src.toString()) |
36526 | 121 |
.outdir(classes) |
122 |
.files(findJavaFiles(src)) |
|
123 |
.run() |
|
124 |
.writeAll(); |
|
125 |
} |
|
126 |
||
127 |
@SupportedAnnotationTypes("*") |
|
128 |
public static final class VerifyRequires extends AbstractProcessor { |
|
129 |
||
130 |
@Override |
|
131 |
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { |
|
132 |
ModuleElement m2Module = processingEnv.getElementUtils().getModuleElement("m2"); |
|
133 |
if (m2Module == null) { |
|
134 |
throw new AssertionError("Cannot find the m2 module!"); |
|
135 |
} |
|
136 |
boolean foundM1 = false; |
|
137 |
for (RequiresDirective rd : ElementFilter.requiresIn(m2Module.getDirectives())) { |
|
138 |
foundM1 |= rd.getDependency().getSimpleName().contentEquals("m1"); |
|
139 |
} |
|
140 |
if (!foundM1) { |
|
141 |
throw new AssertionError("Cannot find the dependency on m1 module!"); |
|
142 |
} |
|
143 |
return false; |
|
144 |
} |
|
145 |
||
146 |
@Override |
|
147 |
public SourceVersion getSupportedSourceVersion() { |
|
148 |
return SourceVersion.latest(); |
|
149 |
} |
|
150 |
||
151 |
} |
|
152 |
||
153 |
@Test |
|
37758 | 154 |
public void testAddReadsUnnamedModule(Path base) throws Exception { |
36526 | 155 |
Path jar = prepareTestJar(base); |
156 |
||
157 |
Path moduleSrc = base.resolve("module-src"); |
|
158 |
Path m1 = moduleSrc.resolve("m1"); |
|
159 |
||
160 |
Path classes = base.resolve("classes"); |
|
161 |
||
162 |
Files.createDirectories(classes); |
|
163 |
||
164 |
tb.writeJavaFiles(m1, |
|
165 |
"module m1 { }", |
|
166 |
"package impl; public class Impl { api.Api api; }"); |
|
167 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
168 |
new JavacTask(tb) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
169 |
.options("--class-path", jar.toString(), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
170 |
"--add-reads", "m1=ALL-UNNAMED", |
36526 | 171 |
"-XDrawDiagnostics") |
172 |
.outdir(classes) |
|
173 |
.files(findJavaFiles(moduleSrc)) |
|
174 |
.run() |
|
175 |
.writeAll(); |
|
176 |
} |
|
177 |
||
178 |
@Test |
|
37758 | 179 |
public void testAddReadsUnnamedModulePackageConflict(Path base) throws Exception { |
36526 | 180 |
Path jar = prepareTestJar(base); |
181 |
||
182 |
Path moduleSrc = base.resolve("module-src"); |
|
183 |
Path m1 = moduleSrc.resolve("m1"); |
|
184 |
||
185 |
Path classes = base.resolve("classes"); |
|
186 |
||
187 |
Files.createDirectories(classes); |
|
188 |
||
189 |
tb.writeJavaFiles(m1, |
|
190 |
"module m1 { }", |
|
191 |
"package api; public class Api { public static void test() { } }", |
|
192 |
"package impl; public class Impl { { api.Api.test(); } }"); |
|
193 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
194 |
new JavacTask(tb) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
195 |
.options("--class-path", jar.toString(), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
196 |
"--module-source-path", moduleSrc.toString(), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
197 |
"--add-reads", "m1=ALL-UNNAMED", |
36526 | 198 |
"-XDrawDiagnostics") |
199 |
.outdir(classes) |
|
200 |
.files(m1.resolve("impl").resolve("Impl.java")) |
|
201 |
.run() |
|
202 |
.writeAll(); |
|
203 |
} |
|
204 |
||
205 |
@Test |
|
37758 | 206 |
public void testAddReadsUnnamedToJavaBase(Path base) throws Exception { |
36526 | 207 |
Path jar = prepareTestJar(base); |
208 |
Path src = base.resolve("src"); |
|
209 |
Path classes = base.resolve("classes"); |
|
210 |
||
211 |
Files.createDirectories(classes); |
|
212 |
||
213 |
tb.writeJavaFiles(src, |
|
214 |
"package impl; public class Impl { api.Api a; }"); |
|
215 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
216 |
new JavacTask(tb) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
217 |
.options("--class-path", jar.toString(), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
218 |
"--add-reads", "java.base=ALL-UNNAMED", |
36526 | 219 |
"-Xmodule:java.base") |
220 |
.outdir(classes) |
|
221 |
.files(src.resolve("impl").resolve("Impl.java")) |
|
222 |
.run() |
|
223 |
.writeAll(); |
|
224 |
} |
|
225 |
||
226 |
@Test |
|
37758 | 227 |
public void testAddReadsToJavaBase(Path base) throws Exception { |
36526 | 228 |
Path src = base.resolve("src"); |
229 |
Path classes = base.resolve("classes"); |
|
230 |
||
231 |
Files.createDirectories(classes); |
|
232 |
||
233 |
tb.writeJavaFiles(src, |
|
234 |
"package impl; public class Impl { javax.swing.JButton b; }"); |
|
235 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
236 |
new JavacTask(tb) |
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
237 |
.options("--add-modules", "java.desktop", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
238 |
"--add-reads", "java.base=java.desktop", |
36526 | 239 |
"-Xmodule:java.base") |
240 |
.outdir(classes) |
|
241 |
.files(findJavaFiles(src)) |
|
242 |
.run() |
|
243 |
.writeAll(); |
|
244 |
} |
|
245 |
||
246 |
private Path prepareTestJar(Path base) throws Exception { |
|
247 |
Path legacySrc = base.resolve("legacy-src"); |
|
248 |
tb.writeJavaFiles(legacySrc, |
|
249 |
"package api; public abstract class Api {}"); |
|
250 |
Path legacyClasses = base.resolve("legacy-classes"); |
|
251 |
Files.createDirectories(legacyClasses); |
|
252 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
253 |
String log = new JavacTask(tb) |
36526 | 254 |
.options() |
255 |
.outdir(legacyClasses) |
|
256 |
.files(findJavaFiles(legacySrc)) |
|
257 |
.run() |
|
258 |
.writeAll() |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
259 |
.getOutput(Task.OutputKind.DIRECT); |
36526 | 260 |
|
261 |
if (!log.isEmpty()) { |
|
262 |
throw new Exception("unexpected output: " + log); |
|
263 |
} |
|
264 |
||
265 |
Path lib = base.resolve("lib"); |
|
266 |
||
267 |
Files.createDirectories(lib); |
|
268 |
||
269 |
Path jar = lib.resolve("test-api-1.0.jar"); |
|
270 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
271 |
new JarTask(tb, jar) |
36526 | 272 |
.baseDir(legacyClasses) |
273 |
.files("api/Api.class") |
|
274 |
.run(); |
|
275 |
||
276 |
return jar; |
|
277 |
} |
|
278 |
||
279 |
@Test |
|
37758 | 280 |
public void testX(Path base) throws Exception { |
36526 | 281 |
Path src = base.resolve("src"); |
282 |
Path src_m1 = src.resolve("m1"); |
|
283 |
tb.writeJavaFiles(src_m1, |
|
284 |
"module m1 { provides java.lang.Runnable with impl.Impl; }", |
|
285 |
"package impl; public class Impl implements Runnable { public void run() { } }"); |
|
286 |
Path classes = base.resolve("classes"); |
|
287 |
tb.createDirectories(classes); |
|
288 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
289 |
new JavacTask(tb) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
290 |
.options("--module-source-path", src.toString()) |
36526 | 291 |
.outdir(classes) |
292 |
.files(findJavaFiles(src)) |
|
293 |
.run() |
|
294 |
.writeAll(); |
|
295 |
||
296 |
Path unnamedSrc = base.resolve("unnamed-src"); |
|
297 |
Path unnamedClasses = base.resolve("unnamed-classes"); |
|
298 |
||
299 |
Files.createDirectories(unnamedClasses); |
|
300 |
||
301 |
tb.writeJavaFiles(unnamedSrc, |
|
302 |
"package impl; public class Impl { }"); |
|
303 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
304 |
new JavacTask(tb) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
305 |
.options("--add-reads", "m1=ALL-UNNAMED", |
36526 | 306 |
"-Xmodule:m1", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
307 |
"--module-path", classes.toString()) |
36526 | 308 |
.outdir(unnamedClasses) |
309 |
.files(findJavaFiles(unnamedSrc)) |
|
310 |
.run() |
|
311 |
.writeAll(); |
|
312 |
} |
|
41938
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
313 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
314 |
@Test |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
315 |
public void testAddSelf(Path base) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
316 |
Path src = base.resolve("src"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
317 |
Path src_m1 = src.resolve("m1"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
318 |
tb.writeJavaFiles(src_m1, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
319 |
"module m1 { exports p1; }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
320 |
"package p1; public class C1 { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
321 |
Path classes = base.resolve("classes"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
322 |
tb.createDirectories(classes); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
323 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
324 |
new JavacTask(tb) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
325 |
.options("--module-source-path", src.toString(), |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
326 |
"--add-reads", "m1=m1") |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
327 |
.outdir(classes) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
328 |
.files(findJavaFiles(src)) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
329 |
.run() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
330 |
.writeAll(); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
331 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
332 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
333 |
@Test |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
334 |
public void testEmpty(Path base) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
335 |
Path src = base.resolve("src"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
336 |
tb.writeJavaFiles(src, "class Dummy { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
337 |
Path classes = base.resolve("classes"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
338 |
tb.createDirectories(classes); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
339 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
340 |
testEmpty(src, classes, "--add-reads", ""); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
341 |
testEmpty(src, classes, "--add-reads="); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
342 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
343 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
344 |
private void testEmpty(Path src, Path classes, String... options) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
345 |
String log = new JavacTask(tb, Task.Mode.CMDLINE) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
346 |
.options(options) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
347 |
.outdir(classes) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
348 |
.files(findJavaFiles(src)) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
349 |
.run(Task.Expect.FAIL) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
350 |
.writeAll() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
351 |
.getOutput(Task.OutputKind.DIRECT); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
352 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
353 |
checkOutputContains(log, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
354 |
"javac: no value for --add-reads option"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
355 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
356 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
357 |
@Test |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
358 |
public void testEmptyItem(Path base) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
359 |
Path src = base.resolve("src"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
360 |
Path src_m1 = src.resolve("m1"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
361 |
tb.writeJavaFiles(src_m1, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
362 |
"module m1 { exports p1; }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
363 |
"package p1; public class C1 { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
364 |
Path src_m2 = src.resolve("m2"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
365 |
tb.writeJavaFiles(src_m2, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
366 |
"module m2 { }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
367 |
"package p2; class C2 { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
368 |
Path src_m3 = src.resolve("m3"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
369 |
tb.writeJavaFiles(src_m3, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
370 |
"module m3 { }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
371 |
"package p3; class C3 { p1.C1 c1; }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
372 |
Path classes = base.resolve("classes"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
373 |
tb.createDirectories(classes); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
374 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
375 |
testEmptyItem(src, classes, "m3=,m1"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
376 |
testEmptyItem(src, classes, "m3=m1,,m2"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
377 |
testEmptyItem(src, classes, "m3=m1,"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
378 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
379 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
380 |
private void testEmptyItem(Path src, Path classes, String option) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
381 |
new JavacTask(tb) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
382 |
.options("--module-source-path", src.toString(), |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
383 |
"--add-reads", option) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
384 |
.outdir(classes) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
385 |
.files(findJavaFiles(src)) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
386 |
.run() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
387 |
.writeAll(); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
388 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
389 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
390 |
@Test |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
391 |
public void testEmptyList(Path base) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
392 |
Path src = base.resolve("src"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
393 |
Path src_m1 = src.resolve("m1"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
394 |
tb.writeJavaFiles(src_m1, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
395 |
"module m1 { exports p1; }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
396 |
"package p1; public class C1 { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
397 |
Path src_m2 = src.resolve("m2"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
398 |
tb.writeJavaFiles(src_m2, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
399 |
"module m2 { }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
400 |
"package p2; class C2 { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
401 |
Path src_m3 = src.resolve("m3"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
402 |
tb.writeJavaFiles(src_m3, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
403 |
"module m3 { }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
404 |
"package p3; class C3 { p1.C1 c1; }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
405 |
Path classes = base.resolve("classes"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
406 |
tb.createDirectories(classes); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
407 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
408 |
testEmptyList(src, classes, "m3="); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
409 |
testEmptyList(src, classes, "m3=,"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
410 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
411 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
412 |
private void testEmptyList(Path src, Path classes, String option) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
413 |
String log = new JavacTask(tb, Task.Mode.CMDLINE) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
414 |
.options("--module-source-path", src.toString(), |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
415 |
"--add-reads", option) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
416 |
.outdir(classes) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
417 |
.files(findJavaFiles(src)) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
418 |
.run(Task.Expect.FAIL) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
419 |
.writeAll() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
420 |
.getOutput(Task.OutputKind.DIRECT); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
421 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
422 |
checkOutputContains(log, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
423 |
"javac: bad value for --add-reads option: '" + option + "'"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
424 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
425 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
426 |
@Test |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
427 |
public void testMultipleAddReads_DifferentModules(Path base) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
428 |
Path src = base.resolve("src"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
429 |
Path src_m1 = src.resolve("m1"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
430 |
tb.writeJavaFiles(src_m1, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
431 |
"module m1 { exports p1; }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
432 |
"package p1; public class C1 { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
433 |
Path src_m2 = src.resolve("m2"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
434 |
tb.writeJavaFiles(src_m2, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
435 |
"module m2 { }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
436 |
"package p2; class C2 { p1.C1 c1; }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
437 |
Path src_m3 = src.resolve("m3"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
438 |
tb.writeJavaFiles(src_m3, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
439 |
"module m3 { }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
440 |
"package p3; class C3 { p1.C1 c1; }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
441 |
Path classes = base.resolve("classes"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
442 |
tb.createDirectories(classes); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
443 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
444 |
new JavacTask(tb) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
445 |
.options("--module-source-path", src.toString(), |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
446 |
"--add-reads", "m2=m1", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
447 |
"--add-reads", "m3=m1") |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
448 |
.outdir(classes) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
449 |
.files(findJavaFiles(src)) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
450 |
.run() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
451 |
.writeAll(); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
452 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
453 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
454 |
@Test |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
455 |
public void testMultipleAddReads_SameModule(Path base) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
456 |
Path src = base.resolve("src"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
457 |
Path src_m1 = src.resolve("m1"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
458 |
tb.writeJavaFiles(src_m1, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
459 |
"module m1 { exports p1; }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
460 |
"package p1; public class C1 { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
461 |
Path src_m2 = src.resolve("m2"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
462 |
tb.writeJavaFiles(src_m2, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
463 |
"module m2 { exports p2; }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
464 |
"package p2; public class C2 { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
465 |
Path src_m3 = src.resolve("m3"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
466 |
tb.writeJavaFiles(src_m3, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
467 |
"module m3 { }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
468 |
"package p3; class C3 { p1.C1 c1; p2.C2 c2; }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
469 |
Path classes = base.resolve("classes"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
470 |
tb.createDirectories(classes); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
471 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
472 |
new JavacTask(tb) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
473 |
.options("--module-source-path", src.toString(), |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
474 |
"--add-reads", "m3=m1", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
475 |
"--add-reads", "m3=m2") |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
476 |
.outdir(classes) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
477 |
.files(findJavaFiles(src)) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
478 |
.run() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
479 |
.writeAll(); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
480 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
481 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
482 |
@Test |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
483 |
public void testDuplicateAddReads_SameOption(Path base) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
484 |
Path src = base.resolve("src"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
485 |
Path src_m1 = src.resolve("m1"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
486 |
tb.writeJavaFiles(src_m1, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
487 |
"module m1 { exports p1; }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
488 |
"package p1; public class C1 { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
489 |
Path src_m2 = src.resolve("m2"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
490 |
tb.writeJavaFiles(src_m2, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
491 |
"module m2 { exports p2; }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
492 |
"package p2; class C2 { p1.C1 c1; }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
493 |
Path classes = base.resolve("classes"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
494 |
tb.createDirectories(classes); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
495 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
496 |
new JavacTask(tb) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
497 |
.options("--module-source-path", src.toString(), |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
498 |
"--add-reads", "m2=m1,m1") |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
499 |
.outdir(classes) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
500 |
.files(findJavaFiles(src)) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
501 |
.run() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
502 |
.writeAll(); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
503 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
504 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
505 |
@Test |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
506 |
public void testDuplicateAddReads_MultipleOptions(Path base) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
507 |
Path src = base.resolve("src"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
508 |
Path src_m1 = src.resolve("m1"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
509 |
tb.writeJavaFiles(src_m1, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
510 |
"module m1 { exports p1; }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
511 |
"package p1; public class C1 { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
512 |
Path src_m2 = src.resolve("m2"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
513 |
tb.writeJavaFiles(src_m2, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
514 |
"module m2 { }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
515 |
"package p2; class C2 { p1.C1 c1; }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
516 |
Path classes = base.resolve("classes"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
517 |
tb.createDirectories(classes); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
518 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
519 |
new JavacTask(tb) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
520 |
.options("--module-source-path", src.toString(), |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
521 |
"--add-reads", "m2=m1", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
522 |
"--add-reads", "m2=m1") |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
523 |
.outdir(classes) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
524 |
.files(findJavaFiles(src)) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
525 |
.run() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
526 |
.writeAll(); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
527 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
528 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
529 |
@Test |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
530 |
public void testRepeatedAddReads(Path base) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
531 |
Path src = base.resolve("src"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
532 |
Path src_m1 = src.resolve("m1"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
533 |
tb.writeJavaFiles(src_m1, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
534 |
"module m1 { exports p1; }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
535 |
"package p1; public class C1 { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
536 |
Path src_m2 = src.resolve("m2"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
537 |
tb.writeJavaFiles(src_m2, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
538 |
"module m2 { exports p2; }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
539 |
"package p2; public class C2 { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
540 |
Path src_m3 = src.resolve("m3"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
541 |
tb.writeJavaFiles(src_m3, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
542 |
"module m3 { }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
543 |
"package p3; class C3 { p1.C1 c1; p2.C2 c2; }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
544 |
Path classes = base.resolve("classes"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
545 |
tb.createDirectories(classes); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
546 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
547 |
new JavacTask(tb) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
548 |
.options("--module-source-path", src.toString(), |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
549 |
"--add-reads", "m3=m1", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
550 |
"--add-reads", "m3=m2") |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
551 |
.outdir(classes) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
552 |
.files(findJavaFiles(src)) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
553 |
.run() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
554 |
.writeAll(); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
555 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
556 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
557 |
@Test |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
558 |
public void testNoEquals(Path base) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
559 |
Path src = base.resolve("src"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
560 |
tb.writeJavaFiles(src, "class Dummy { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
561 |
Path classes = base.resolve("classes"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
562 |
tb.createDirectories(classes); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
563 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
564 |
String log = new JavacTask(tb, Task.Mode.CMDLINE) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
565 |
.options("-XDrawDiagnostics", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
566 |
"--add-reads", "m1:m2") |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
567 |
.outdir(classes) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
568 |
.files(findJavaFiles(src)) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
569 |
.run(Task.Expect.FAIL) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
570 |
.writeAll() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
571 |
.getOutput(Task.OutputKind.DIRECT); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
572 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
573 |
checkOutputContains(log, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
574 |
"javac: bad value for --add-reads option: 'm1:m2'"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
575 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
576 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
577 |
@Test |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
578 |
public void testBadSourceName(Path base) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
579 |
Path src = base.resolve("src"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
580 |
tb.writeJavaFiles(src, "class Dummy { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
581 |
Path classes = base.resolve("classes"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
582 |
tb.createDirectories(classes); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
583 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
584 |
String log = new JavacTask(tb) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
585 |
.options("-XDrawDiagnostics", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
586 |
"--add-reads", "bad*Source=m2") |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
587 |
.outdir(classes) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
588 |
.files(findJavaFiles(src)) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
589 |
.run() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
590 |
.writeAll() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
591 |
.getOutput(Task.OutputKind.DIRECT); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
592 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
593 |
checkOutputContains(log, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
594 |
"- compiler.warn.bad.name.for.option: --add-reads, bad*Source"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
595 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
596 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
597 |
@Test |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
598 |
public void testBadTargetName(Path base) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
599 |
Path src = base.resolve("src"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
600 |
Path src_m1 = src.resolve("m1"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
601 |
tb.writeJavaFiles(src_m1, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
602 |
"module m1 { }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
603 |
"package p1; class C1 { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
604 |
Path classes = base.resolve("classes"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
605 |
tb.createDirectories(classes); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
606 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
607 |
String log = new JavacTask(tb) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
608 |
.options("-XDrawDiagnostics", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
609 |
"--add-reads", "m1=badTarget!") |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
610 |
.outdir(classes) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
611 |
.files(findJavaFiles(src)) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
612 |
.run() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
613 |
.writeAll() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
614 |
.getOutput(Task.OutputKind.DIRECT); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
615 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
616 |
checkOutputContains(log, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
617 |
"- compiler.warn.bad.name.for.option: --add-reads, badTarget!"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
618 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
619 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
620 |
@Test |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
621 |
public void testSourceNameNotFound(Path base) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
622 |
Path src = base.resolve("src"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
623 |
Path src_m1 = src.resolve("m1"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
624 |
tb.writeJavaFiles(src_m1, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
625 |
"module m1 { exports p1; }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
626 |
"package p1; public class C1 { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
627 |
Path classes = base.resolve("classes"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
628 |
tb.createDirectories(classes); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
629 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
630 |
String log = new JavacTask(tb) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
631 |
.options("-XDrawDiagnostics", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
632 |
"--add-reads", "missingSource=m1") |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
633 |
.outdir(classes) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
634 |
.files(findJavaFiles(src)) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
635 |
.run() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
636 |
.writeAll() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
637 |
.getOutput(Task.OutputKind.DIRECT); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
638 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
639 |
checkOutputContains(log, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
640 |
"- compiler.warn.module.for.option.not.found: --add-reads, missingSource"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
641 |
} |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
642 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
643 |
@Test |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
644 |
public void testTargetNameNotFound(Path base) throws Exception { |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
645 |
Path src = base.resolve("src"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
646 |
Path src_m1 = src.resolve("m1"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
647 |
tb.writeJavaFiles(src_m1, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
648 |
"module m1 { exports p1; }", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
649 |
"package p1; public class C1 { }"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
650 |
Path classes = base.resolve("classes"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
651 |
tb.createDirectories(classes); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
652 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
653 |
String log = new JavacTask(tb) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
654 |
.options("-XDrawDiagnostics", |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
655 |
"--add-reads", "m1=missingTarget") |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
656 |
.outdir(classes) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
657 |
.files(findJavaFiles(src)) |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
658 |
.run() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
659 |
.writeAll() |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
660 |
.getOutput(Task.OutputKind.DIRECT); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
661 |
|
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
662 |
checkOutputContains(log, |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
663 |
"- compiler.warn.module.for.option.not.found: --add-reads, missingTarget"); |
8e66bf10fcec
8167975: align javac --add-* modules options with launcher
jjg
parents:
41932
diff
changeset
|
664 |
} |
36526 | 665 |
} |