author | jjg |
Fri, 31 Aug 2018 14:54:42 -0700 | |
changeset 51615 | afbb33428df7 |
parent 49822 | 53aae0c219e6 |
permissions | -rw-r--r-- |
36526 | 1 |
/* |
49822
53aae0c219e6
8196433: use the new error diagnostic approach at javac.Main
vromero
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. |
36526 | 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 |
|
40599
be40838eb215
8164887: update tests to remove use of old-style options
jjg
parents:
40308
diff
changeset
|
26 |
* @summary tests for --module-source-path |
36526 | 27 |
* @library /tools/lib |
28 |
* @modules |
|
29 |
* jdk.compiler/com.sun.tools.javac.api |
|
30 |
* jdk.compiler/com.sun.tools.javac.main |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
31 |
* @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase |
36526 | 32 |
* @run main ModuleSourcePathTest |
33 |
*/ |
|
34 |
||
35 |
import java.io.File; |
|
36 |
import java.io.IOException; |
|
37 |
import java.nio.file.Files; |
|
38 |
import java.nio.file.Path; |
|
39 |
import java.nio.file.Paths; |
|
44690
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
40 |
import java.util.ArrayList; |
36526 | 41 |
import java.util.Arrays; |
42 |
import java.util.List; |
|
43 |
import java.util.stream.Collectors; |
|
44 |
import java.util.stream.Stream; |
|
45 |
||
44690
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
46 |
import javax.tools.JavaCompiler; |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
47 |
import javax.tools.JavaFileManager.Location; |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
48 |
import javax.tools.StandardJavaFileManager; |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
49 |
import javax.tools.StandardLocation; |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
50 |
import javax.tools.ToolProvider; |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
51 |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
52 |
import toolbox.JavacTask; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
53 |
import toolbox.Task; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
54 |
import toolbox.ToolBox; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
55 |
|
36526 | 56 |
public class ModuleSourcePathTest extends ModuleTestBase { |
57 |
||
58 |
public static final char PATH_SEP = File.pathSeparatorChar; |
|
59 |
||
60 |
public static void main(String... args) throws Exception { |
|
61 |
ModuleSourcePathTest t = new ModuleSourcePathTest(); |
|
62 |
t.runTests(); |
|
63 |
} |
|
64 |
||
65 |
@Test |
|
37758 | 66 |
public void testSourcePathConflict(Path base) throws Exception { |
36526 | 67 |
Path sp = base.resolve("src"); |
68 |
Path msp = base.resolve("srcmodules"); |
|
69 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
70 |
String log = new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 71 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
72 |
"--source-path", sp.toString().replace('/', File.separatorChar), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
73 |
"--module-source-path", msp.toString().replace('/', File.separatorChar), |
36526 | 74 |
"dummyClass") |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
75 |
.run(Task.Expect.FAIL) |
36526 | 76 |
.writeAll() |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
77 |
.getOutput(Task.OutputKind.DIRECT); |
36526 | 78 |
|
49822
53aae0c219e6
8196433: use the new error diagnostic approach at javac.Main
vromero
parents:
47216
diff
changeset
|
79 |
if (!log.contains("compiler.err.sourcepath.modulesourcepath.conflict")) |
36526 | 80 |
throw new Exception("expected diagnostic not found"); |
81 |
} |
|
82 |
||
83 |
@Test |
|
37758 | 84 |
public void testUnnormalizedPath1(Path base) throws Exception { |
36526 | 85 |
Path src = base.resolve("src"); |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
86 |
Path src_m1 = src.resolve("m1x"); |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
87 |
tb.writeJavaFiles(src_m1, "module m1x { }"); |
36526 | 88 |
Path modules = base.resolve("modules"); |
89 |
Files.createDirectories(modules); |
|
90 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
91 |
new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 92 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
93 |
"--module-source-path", src.toString()) |
36526 | 94 |
.outdir(modules) |
95 |
.files(prefixAll(findJavaFiles(src), Paths.get("./"))) |
|
96 |
.run() |
|
97 |
.writeAll(); |
|
98 |
} |
|
99 |
||
100 |
@Test |
|
37758 | 101 |
public void testUnnormalizedPath2(Path base) throws Exception { |
36526 | 102 |
Path src = base.resolve("src"); |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
103 |
Path src_m1 = src.resolve("m1x"); |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
104 |
tb.writeJavaFiles(src_m1, "module m1x { }"); |
36526 | 105 |
Path modules = base.resolve("modules"); |
106 |
Files.createDirectories(modules); |
|
107 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
108 |
new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 109 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
110 |
"--module-source-path", "./" + src) |
36526 | 111 |
.outdir(modules) |
112 |
.files(findJavaFiles(src)) |
|
113 |
.run() |
|
114 |
.writeAll(); |
|
115 |
} |
|
116 |
||
117 |
private Path[] prefixAll(Path[] paths, Path prefix) { |
|
118 |
return Stream.of(paths) |
|
119 |
.map(prefix::resolve) |
|
120 |
.collect(Collectors.toList()) |
|
121 |
.toArray(new Path[paths.length]); |
|
122 |
} |
|
123 |
||
124 |
@Test |
|
37758 | 125 |
public void regularBraces(Path base) throws Exception { |
36526 | 126 |
generateModules(base, "src1", "src2/inner_dir"); |
127 |
||
128 |
final Path modules = base.resolve("modules"); |
|
129 |
tb.createDirectories(modules); |
|
130 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
131 |
new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 132 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
133 |
"--module-source-path", base + "/{src1,src2/inner_dir}") |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
134 |
.files(base.resolve("src1/m0x/pkg0/A.java"), base.resolve("src2/inner_dir/m1x/pkg1/A.java")) |
36526 | 135 |
.outdir(modules) |
136 |
.run() |
|
137 |
.writeAll(); |
|
138 |
||
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
139 |
checkFiles(modules.resolve("m0x/pkg0/A.class"), |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
140 |
modules.resolve("m1x/pkg1/A.class"), |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
141 |
modules.resolve("m0x/module-info.class"), |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
142 |
modules.resolve("m1x/module-info.class")); |
36526 | 143 |
} |
144 |
||
145 |
@Test |
|
37758 | 146 |
public void mismatchedBraces(Path base) throws Exception { |
36526 | 147 |
final List<String> sourcePaths = Arrays.asList( |
148 |
"{", |
|
149 |
"}", |
|
150 |
"}{", |
|
151 |
"./}", |
|
152 |
".././{./", |
|
153 |
"src{}}", |
|
154 |
"{{}{}}{}}", |
|
155 |
"src/{a,b}/{", |
|
156 |
"src/{a,{,{}}", |
|
157 |
"{.,..{}/src", |
|
158 |
"*}{", |
|
159 |
"{}*}" |
|
160 |
); |
|
161 |
for (String sourcepath : sourcePaths) { |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
162 |
String log = new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 163 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
164 |
"--module-source-path", sourcepath.replace('/', File.separatorChar)) |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
165 |
.run(Task.Expect.FAIL) |
36526 | 166 |
.writeAll() |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
167 |
.getOutput(Task.OutputKind.DIRECT); |
36526 | 168 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
169 |
if (!log.contains("- compiler.err.illegal.argument.for.option: --module-source-path, mismatched braces")) |
36526 | 170 |
throw new Exception("expected output for path [" + sourcepath + "] not found"); |
171 |
} |
|
172 |
} |
|
173 |
||
174 |
@Test |
|
37758 | 175 |
public void deepBraces(Path base) throws Exception { |
36526 | 176 |
String[] modulePaths = {"src/src1", |
177 |
"src/src2", |
|
178 |
"src/src3", |
|
179 |
"src/srcB/src1", |
|
180 |
"src/srcB/src2/srcXX", |
|
181 |
"src/srcB/src2/srcXY", |
|
182 |
"src/srcC/src1", |
|
183 |
"src/srcC/src2/srcXX", |
|
184 |
"src/srcC/src2/srcXY"}; |
|
185 |
generateModules(base, modulePaths); |
|
186 |
||
187 |
final Path modules = base.resolve("modules"); |
|
188 |
tb.createDirectories(modules); |
|
189 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
190 |
new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 191 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
192 |
"--module-source-path", |
36526 | 193 |
base + "/{src/{{src1,src2,src3},{srcB,srcC}/{src1,src2/srcX{X,Y}/}},.}" |
194 |
.replace('/', File.separatorChar)) |
|
195 |
.files(findJavaFiles(base.resolve(modulePaths[modulePaths.length - 1]))) |
|
196 |
.outdir(modules) |
|
197 |
.run() |
|
198 |
.writeAll(); |
|
199 |
||
200 |
for (int i = 0; i < modulePaths.length; i++) { |
|
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
201 |
checkFiles(modules.resolve("m" + i + "x/module-info.class")); |
36526 | 202 |
} |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
203 |
checkFiles(modules.resolve("m8x/pkg8/A.class")); |
36526 | 204 |
} |
205 |
||
206 |
@Test |
|
37758 | 207 |
public void fileInPath(Path base) throws Exception { |
36526 | 208 |
Path src = base.resolve("src"); |
209 |
tb.writeJavaFiles(src.resolve("kettle$"), "module kettle$ { }", "package electric; class Heater { }"); |
|
210 |
tb.writeFile(base.resolve("dummy.txt"), ""); |
|
211 |
||
212 |
final Path modules = base.resolve("modules"); |
|
213 |
tb.createDirectories(modules); |
|
214 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
215 |
new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 216 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
217 |
"--module-source-path", base + "/{dummy.txt,src}") |
36526 | 218 |
.files(src.resolve("kettle$/electric/Heater.java")) |
219 |
.outdir(modules) |
|
220 |
.run() |
|
221 |
.writeAll(); |
|
222 |
||
223 |
checkFiles(modules.resolve("kettle$/electric/Heater.class")); |
|
224 |
checkFiles(modules.resolve("kettle$/module-info.class")); |
|
225 |
} |
|
226 |
||
227 |
@Test |
|
37758 | 228 |
public void noAlternative(Path base) throws Exception { |
36526 | 229 |
Path src = base.resolve("src"); |
230 |
tb.writeJavaFiles(src.resolve("kettle$"), "module kettle$ { }", "package electric; class Heater { }"); |
|
231 |
||
232 |
final Path modules = base.resolve("modules"); |
|
233 |
tb.createDirectories(modules); |
|
234 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
235 |
new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 236 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
237 |
"--module-source-path", base + "/{src}") |
36526 | 238 |
.files(src.resolve("kettle$/electric/Heater.java")) |
239 |
.outdir(modules) |
|
240 |
.run() |
|
241 |
.writeAll(); |
|
242 |
||
243 |
checkFiles(modules.resolve("kettle$/electric/Heater.class")); |
|
244 |
checkFiles(modules.resolve("kettle$/module-info.class")); |
|
245 |
} |
|
246 |
||
247 |
@Test |
|
37758 | 248 |
public void noChoice(Path base) throws Exception { |
36526 | 249 |
tb.writeJavaFiles(base.resolve("kettle$"), "module kettle$ { }", "package electric; class Heater { }"); |
250 |
||
251 |
final Path modules = base.resolve("modules"); |
|
252 |
tb.createDirectories(modules); |
|
253 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
254 |
new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 255 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
256 |
"--module-source-path", base + "/{}") |
36526 | 257 |
.files(base.resolve("kettle$/electric/Heater.java")) |
258 |
.outdir(modules) |
|
259 |
.run() |
|
260 |
.writeAll(); |
|
261 |
||
262 |
checkFiles(modules.resolve("kettle$/electric/Heater.class")); |
|
263 |
checkFiles(modules.resolve("kettle$/module-info.class")); |
|
264 |
} |
|
265 |
||
266 |
@Test |
|
37758 | 267 |
public void nestedModules(Path src) throws Exception { |
36526 | 268 |
Path carModule = src.resolve("car"); |
269 |
tb.writeJavaFiles(carModule, "module car { }", "package light; class Headlight { }"); |
|
270 |
tb.writeJavaFiles(carModule.resolve("engine"), "module engine { }", "package flat; class Piston { }"); |
|
271 |
||
272 |
final Path modules = src.resolve("modules"); |
|
273 |
tb.createDirectories(modules); |
|
274 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
275 |
new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 276 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
277 |
"--module-source-path", "{" + src + "," + src + "/car}") |
36526 | 278 |
.files(findJavaFiles(src)) |
279 |
.outdir(modules) |
|
280 |
.run() |
|
281 |
.writeAll(); |
|
282 |
checkFiles(modules.resolve("car/light/Headlight.class")); |
|
283 |
checkFiles(modules.resolve("engine/flat/Piston.class")); |
|
284 |
} |
|
285 |
||
286 |
@Test |
|
37758 | 287 |
public void relativePaths(Path base) throws Exception { |
36526 | 288 |
Path src = base.resolve("src"); |
289 |
tb.writeJavaFiles(src.resolve("kettle"), "module kettle { }", "package electric; class Heater { }"); |
|
290 |
||
291 |
final Path modules = base.resolve("modules"); |
|
292 |
tb.createDirectories(modules); |
|
293 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
294 |
new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 295 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
296 |
"--module-source-path", base + "/src/./../src") |
36526 | 297 |
.files(src.resolve("kettle/electric/Heater.java")) |
298 |
.outdir(modules) |
|
299 |
.run() |
|
300 |
.writeAll(); |
|
301 |
checkFiles(modules.resolve("kettle/electric/Heater.class")); |
|
302 |
checkFiles(modules.resolve("kettle/module-info.class")); |
|
303 |
} |
|
304 |
||
305 |
@Test |
|
37758 | 306 |
public void duplicatePaths(Path base) throws Exception { |
36526 | 307 |
Path src = base.resolve("src"); |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
308 |
tb.writeJavaFiles(src.resolve("m1x"), "module m1x { }", "package a; class A { }"); |
36526 | 309 |
|
310 |
final Path modules = base.resolve("modules"); |
|
311 |
tb.createDirectories(modules); |
|
312 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
313 |
new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 314 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
315 |
"--module-source-path", base + "/{src,src,src}") |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
316 |
.files(src.resolve("m1x/a/A.java")) |
36526 | 317 |
.outdir(modules) |
318 |
.run() |
|
319 |
.writeAll(); |
|
320 |
||
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
321 |
checkFiles(modules.resolve("m1x/module-info.class")); |
36526 | 322 |
} |
323 |
||
324 |
@Test |
|
37758 | 325 |
public void notExistentPaths(Path base) throws Exception { |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
326 |
tb.writeJavaFiles(base.resolve("m1x"), "module m1x { requires m0x; }", "package a; class A { }"); |
36526 | 327 |
|
328 |
final Path modules = base.resolve("modules"); |
|
329 |
tb.createDirectories(modules); |
|
330 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
331 |
String log = new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 332 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
333 |
"--module-source-path", base + "/not_exist" + PATH_SEP + base + "/{not_exist,}") |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
334 |
.files(base.resolve("m1x/a/A.java")) |
36526 | 335 |
.outdir(modules) |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
336 |
.run(Task.Expect.FAIL) |
36526 | 337 |
.writeAll() |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
338 |
.getOutput(Task.OutputKind.DIRECT); |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
339 |
if (!log.contains("compiler.err.module.not.found: m0x")) |
36526 | 340 |
throw new Exception("expected output for not existent module source path not found"); |
341 |
} |
|
342 |
||
343 |
@Test |
|
37758 | 344 |
public void notExistentPathShouldBeSkipped(Path base) throws Exception { |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
345 |
tb.writeJavaFiles(base.resolve("m1x"), "module m1x { }", "package a; class A { }"); |
36526 | 346 |
|
347 |
final Path modules = base.resolve("modules"); |
|
348 |
tb.createDirectories(modules); |
|
349 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
350 |
new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 351 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
352 |
"--module-source-path", base + "{/not_exist,/}") |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
353 |
.files(base.resolve("m1x/a/A.java")) |
36526 | 354 |
.outdir(modules) |
355 |
.run() |
|
356 |
.writeAll(); |
|
357 |
||
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
358 |
checkFiles(modules.resolve("m1x/module-info.class")); |
36526 | 359 |
} |
360 |
||
361 |
@Test |
|
37758 | 362 |
public void commas(Path base) throws Exception { |
36526 | 363 |
Path src = base.resolve("src"); |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
364 |
tb.writeJavaFiles(src.resolve("m1x"), "module m1x { }", "package a; class A { }"); |
36526 | 365 |
|
366 |
final Path modules = base.resolve("modules"); |
|
367 |
tb.createDirectories(modules); |
|
368 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
369 |
new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 370 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
371 |
"--module-source-path", base + "/{,{,,,,src,,,}}") |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
372 |
.files(src.resolve("m1x/a/A.java")) |
36526 | 373 |
.outdir(modules) |
374 |
.run() |
|
375 |
.writeAll(); |
|
376 |
||
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
377 |
checkFiles(modules.resolve("m1x/module-info.class")); |
36526 | 378 |
} |
379 |
||
380 |
@Test |
|
37758 | 381 |
public void asterisk(Path base) throws Exception { |
36526 | 382 |
tb.writeJavaFiles(base.resolve("kettle").resolve("classes"), "module kettle { }", |
383 |
"package electric; class Heater { }"); |
|
384 |
||
385 |
final Path modules = base.resolve("modules"); |
|
386 |
tb.createDirectories(modules); |
|
387 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
388 |
new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 389 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
390 |
"--module-source-path", base + "/*/classes/") |
36526 | 391 |
.files(base.resolve("kettle/classes/electric/Heater.java")) |
392 |
.outdir(modules) |
|
393 |
.run() |
|
394 |
.writeAll(); |
|
395 |
||
396 |
checkFiles(modules.resolve("kettle/electric/Heater.class")); |
|
397 |
checkFiles(modules.resolve("kettle/module-info.class")); |
|
398 |
} |
|
399 |
||
400 |
@Test |
|
37758 | 401 |
public void asteriskInDifferentSets(Path base) throws Exception { |
36526 | 402 |
Path src = base.resolve("src"); |
403 |
final Path module = src.resolve("kettle"); |
|
404 |
tb.writeJavaFiles(module.resolve("classes"), "module kettle { }", "package electric; class Heater { }"); |
|
405 |
tb.writeJavaFiles(module.resolve("gensrc"), "package model; class Java { }"); |
|
406 |
tb.writeJavaFiles(module.resolve("special/classes"), "package gas; class Heater { }"); |
|
407 |
||
408 |
final Path modules = base.resolve("modules"); |
|
409 |
tb.createDirectories(modules); |
|
410 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
411 |
new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 412 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
413 |
"--module-source-path", src + "{/*/gensrc/,/*/classes/}" + PATH_SEP |
36526 | 414 |
+ src + "/*/special/classes") |
415 |
.files(findJavaFiles(src)) |
|
416 |
.outdir(modules) |
|
417 |
.run() |
|
418 |
.writeAll(); |
|
419 |
||
420 |
checkFiles(modules.resolve("kettle/electric/Heater.class")); |
|
421 |
checkFiles(modules.resolve("kettle/gas/Heater.class")); |
|
422 |
checkFiles(modules.resolve("kettle/model/Java.class")); |
|
423 |
checkFiles(modules.resolve("kettle/module-info.class")); |
|
424 |
} |
|
425 |
||
426 |
@Test |
|
37758 | 427 |
public void asteriskIllegalUse(Path base) throws Exception { |
36526 | 428 |
final List<String> sourcePaths = Arrays.asList( |
429 |
"*", |
|
430 |
"**", |
|
431 |
"***", |
|
432 |
"*.*", |
|
433 |
".*", |
|
434 |
"*.", |
|
435 |
"src/*/*/", |
|
436 |
"{*,*}", |
|
437 |
"src/module*/" |
|
438 |
); |
|
439 |
for (String sourcepath : sourcePaths) { |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
440 |
String log = new JavacTask(tb, Task.Mode.CMDLINE) |
36526 | 441 |
.options("-XDrawDiagnostics", |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
442 |
"--module-source-path", sourcepath.replace('/', File.separatorChar)) |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
443 |
.run(Task.Expect.FAIL) |
36526 | 444 |
.writeAll() |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
445 |
.getOutput(Task.OutputKind.DIRECT); |
36526 | 446 |
|
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
37758
diff
changeset
|
447 |
if (!log.contains("- compiler.err.illegal.argument.for.option: --module-source-path, illegal use of *")) |
36526 | 448 |
throw new Exception("expected output for path [" + sourcepath + "] not found"); |
449 |
} |
|
450 |
} |
|
451 |
||
44690
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
452 |
@Test |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
453 |
public void setLocation(Path base) throws Exception { |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
454 |
Path src = base.resolve("src"); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
455 |
tb.writeJavaFiles(src.resolve("m1x"), "module m1x { }", "package a; class A { }"); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
456 |
Path modules = base.resolve("modules"); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
457 |
tb.createDirectories(modules); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
458 |
|
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
459 |
JavaCompiler c = ToolProvider.getSystemJavaCompiler(); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
460 |
try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) { |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
461 |
fm.setLocationFromPaths(StandardLocation.MODULE_SOURCE_PATH, List.of(src)); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
462 |
new JavacTask(tb) |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
463 |
.options("-XDrawDiagnostics") |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
464 |
.fileManager(fm) |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
465 |
.outdir(modules) |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
466 |
.files(findJavaFiles(src)) |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
467 |
.run() |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
468 |
.writeAll(); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
469 |
|
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
470 |
checkFiles(modules.resolve("m1x/module-info.class"), modules.resolve("m1x/a/A.class")); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
471 |
} |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
472 |
} |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
473 |
|
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
474 |
@Test |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
475 |
public void getLocation_valid(Path base) throws Exception { |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
476 |
Path src1 = base.resolve("src1"); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
477 |
tb.writeJavaFiles(src1.resolve("m1x"), "module m1x { }", "package a; class A { }"); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
478 |
Path src2 = base.resolve("src2"); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
479 |
tb.writeJavaFiles(src1.resolve("m2x"), "module m2x { }", "package b; class B { }"); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
480 |
|
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
481 |
JavaCompiler c = ToolProvider.getSystemJavaCompiler(); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
482 |
try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) { |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
483 |
fm.setLocationFromPaths(StandardLocation.MODULE_SOURCE_PATH, List.of(src1, src2)); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
484 |
checkLocation(fm.getLocationAsPaths(StandardLocation.MODULE_SOURCE_PATH), List.of(src1, src2)); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
485 |
} |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
486 |
} |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
487 |
|
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
488 |
@Test |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
489 |
public void getLocation_ISA(Path base) throws Exception { |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
490 |
Path src1 = base.resolve("src1"); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
491 |
tb.writeJavaFiles(src1.resolve("m1x"), "module m1x { }", "package a; class A { }"); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
492 |
Path src2 = base.resolve("src2"); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
493 |
tb.writeJavaFiles(src2.resolve("m2x").resolve("extra"), "module m2x { }", "package b; class B { }"); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
494 |
Path modules = base.resolve("modules"); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
495 |
tb.createDirectories(modules); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
496 |
|
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
497 |
String FS = File.separator; |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
498 |
String PS = File.pathSeparator; |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
499 |
JavaCompiler c = ToolProvider.getSystemJavaCompiler(); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
500 |
try (StandardJavaFileManager fm = c.getStandardFileManager(null, null, null)) { |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
501 |
fm.handleOption("--module-source-path", |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
502 |
List.of(src1 + PS + src2 + FS + "*" + FS + "extra").iterator()); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
503 |
|
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
504 |
try { |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
505 |
Iterable<? extends Path> paths = fm.getLocationAsPaths(StandardLocation.MODULE_SOURCE_PATH); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
506 |
out.println("result: " + asList(paths)); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
507 |
throw new Exception("expected IllegalStateException not thrown"); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
508 |
} catch (IllegalStateException e) { |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
509 |
out.println("Exception thrown, as expected: " + e); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
510 |
} |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
511 |
|
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
512 |
// even if we can't do getLocation for the MODULE_SOURCE_PATH, we should be able |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
513 |
// to do getLocation for the modules, which will additionally confirm the option |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
514 |
// was effective as intended. |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
515 |
Location locn1 = fm.getLocationForModule(StandardLocation.MODULE_SOURCE_PATH, "m1x"); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
516 |
checkLocation(fm.getLocationAsPaths(locn1), List.of(src1.resolve("m1x"))); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
517 |
Location locn2 = fm.getLocationForModule(StandardLocation.MODULE_SOURCE_PATH, "m2x"); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
518 |
checkLocation(fm.getLocationAsPaths(locn2), List.of(src2.resolve("m2x").resolve("extra"))); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
519 |
} |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
520 |
} |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
521 |
|
51615
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
522 |
@Test |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
523 |
public void moduleSpecificFormsOnly(Path base) throws Exception { |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
524 |
// The dirs for the modules do not use a subdirectory named for the module, |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
525 |
// meaning they can only be used by the module-specific form of the option. |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
526 |
String[] srcDirs = { |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
527 |
"src0", // m0x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
528 |
"src1", // m1x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
529 |
"src2", // m2x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
530 |
"src3" // m3x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
531 |
}; |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
532 |
generateModules(base, false, srcDirs); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
533 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
534 |
final Path modules = base.resolve("modules"); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
535 |
tb.createDirectories(modules); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
536 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
537 |
new JavacTask(tb, Task.Mode.CMDLINE) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
538 |
.options("-XDrawDiagnostics", |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
539 |
"--module-source-path", "m0x=" + base.resolve("src0"), |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
540 |
"--module-source-path", "m1x=" + base.resolve("src1"), |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
541 |
"--module-source-path", "m2x=" + base.resolve("src2"), |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
542 |
"--module-source-path", "m3x=" + base.resolve("src3")) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
543 |
.files(findJavaFiles(base.resolve(srcDirs[srcDirs.length - 1]))) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
544 |
.outdir(modules) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
545 |
.run() |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
546 |
.writeAll(); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
547 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
548 |
for (int i = 0; i < srcDirs.length; i++) { |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
549 |
checkFiles(modules.resolve("m" + i + "x/module-info.class")); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
550 |
} |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
551 |
checkFiles(modules.resolve("m3x/pkg3/A.class")); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
552 |
} |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
553 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
554 |
@Test |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
555 |
public void modulePatternWithEquals(Path base) throws Exception { |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
556 |
// The dirs for the modules contain an '=' character, but |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
557 |
// the option should still be recognized as the module pattern form. |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
558 |
String[] srcDirs = { |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
559 |
"src=", // m0x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
560 |
"src=", // m1x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
561 |
"src=", // m2x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
562 |
"src=" // m3x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
563 |
}; |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
564 |
generateModules(base, true, srcDirs); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
565 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
566 |
final Path modules = base.resolve("modules"); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
567 |
tb.createDirectories(modules); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
568 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
569 |
new JavacTask(tb, Task.Mode.CMDLINE) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
570 |
.options("-XDrawDiagnostics", |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
571 |
"--module-source-path", base.resolve("src=").toString()) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
572 |
.files(findJavaFiles(base.resolve(srcDirs[srcDirs.length - 1]))) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
573 |
.outdir(modules) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
574 |
.run() |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
575 |
.writeAll(); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
576 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
577 |
for (int i = 0; i < srcDirs.length; i++) { |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
578 |
checkFiles(modules.resolve("m" + i + "x/module-info.class")); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
579 |
} |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
580 |
checkFiles(modules.resolve("m3x/pkg3/A.class")); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
581 |
} |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
582 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
583 |
@Test |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
584 |
public void duplicateModuleSpecificForms(Path base) throws Exception { |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
585 |
// The dirs for the modules do not use a subdirectory named for the module, |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
586 |
// meaning they can only be used by the module-specific form of the option. |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
587 |
String[] srcDirs = { |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
588 |
"src0", // m0x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
589 |
"src1", // m1x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
590 |
"src2", // m2x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
591 |
"src3" // m3x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
592 |
}; |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
593 |
generateModules(base, false, srcDirs); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
594 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
595 |
final Path modules = base.resolve("modules"); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
596 |
tb.createDirectories(modules); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
597 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
598 |
// in the following, it should not matter that src1 does not contain |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
599 |
// a definition of m0x; it is bad/wrong to specify the option for m0x twice. |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
600 |
String log = new JavacTask(tb, Task.Mode.CMDLINE) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
601 |
.options("-XDrawDiagnostics", |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
602 |
"--module-source-path", "m0x=" + base.resolve("src0"), |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
603 |
"--module-source-path", "m0x=" + base.resolve("src1")) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
604 |
.files(findJavaFiles(base.resolve(srcDirs[srcDirs.length - 1]))) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
605 |
.outdir(modules) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
606 |
.run(Task.Expect.FAIL) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
607 |
.writeAll() |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
608 |
.getOutput(Task.OutputKind.DIRECT); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
609 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
610 |
if (!log.contains("error: --module-source-path specified more than once for module m0x")) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
611 |
throw new Exception("Expected error message not found"); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
612 |
} |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
613 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
614 |
@Test |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
615 |
public void duplicateModulePatternForms(Path base) throws Exception { |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
616 |
// module-specific subdirs are used to allow for use of module-pattern form |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
617 |
String[] srcDirs = { |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
618 |
"src", // m0x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
619 |
"src", // m1x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
620 |
"src", // m2x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
621 |
"src" // m3x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
622 |
}; |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
623 |
generateModules(base, true, srcDirs); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
624 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
625 |
final Path modules = base.resolve("modules"); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
626 |
tb.createDirectories(modules); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
627 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
628 |
// in the following, it should not matter that the same pattern |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
629 |
// is used for both occurrences; it is bad/wrong to give any two patterns |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
630 |
String log = new JavacTask(tb, Task.Mode.CMDLINE) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
631 |
.options("-XDrawDiagnostics", |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
632 |
"--module-source-path", base.resolve("src").toString(), |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
633 |
"--module-source-path", base.resolve("src").toString()) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
634 |
.files(findJavaFiles(base.resolve(srcDirs[srcDirs.length - 1]))) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
635 |
.outdir(modules) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
636 |
.run(Task.Expect.FAIL) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
637 |
.writeAll() |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
638 |
.getOutput(Task.OutputKind.DIRECT); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
639 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
640 |
if (!log.contains("error: --module-source-path specified more than once with a pattern argument")) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
641 |
throw new Exception("Expected error message not found"); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
642 |
} |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
643 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
644 |
@Test |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
645 |
public void mixedOptionForms(Path base) throws Exception { |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
646 |
// The dirs for m0x, m2x use a subdirectory named for the module, |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
647 |
// meaning they can be used in the module pattern form of the option; |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
648 |
// the dirs for m1x, m3x do not use a subdirectory named for the module, |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
649 |
// meaning they can only be used by the module-specific form of the option |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
650 |
String[] srcDirs = { |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
651 |
"src/m0x", // m0x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
652 |
"src1", // m1x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
653 |
"src/m2x", // m2x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
654 |
"src3" // m3x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
655 |
}; |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
656 |
generateModules(base, false, srcDirs); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
657 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
658 |
final Path modules = base.resolve("modules"); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
659 |
tb.createDirectories(modules); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
660 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
661 |
new JavacTask(tb, Task.Mode.CMDLINE) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
662 |
.options("-XDrawDiagnostics", |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
663 |
"--module-source-path", base.resolve("src").toString(), // for m0x, m2x |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
664 |
"--module-source-path", "m1x=" + base.resolve("src1"), |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
665 |
"--module-source-path", "m3x=" + base.resolve("src3")) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
666 |
.files(findJavaFiles(base.resolve(srcDirs[srcDirs.length - 1]))) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
667 |
.outdir(modules) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
668 |
.run() |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
669 |
.writeAll(); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
670 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
671 |
for (int i = 0; i < srcDirs.length; i++) { |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
672 |
checkFiles(modules.resolve("m" + i + "x/module-info.class")); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
673 |
} |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
674 |
checkFiles(modules.resolve("m3x/pkg3/A.class")); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
675 |
} |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
676 |
|
36526 | 677 |
private void generateModules(Path base, String... paths) throws IOException { |
51615
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
678 |
generateModules(base, true, paths); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
679 |
} |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
680 |
|
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
681 |
private void generateModules(Path base, boolean useModuleSubdirs, String... paths) |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
682 |
throws IOException { |
36526 | 683 |
for (int i = 0; i < paths.length; i++) { |
42822
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
684 |
String moduleName = "m" + i + "x"; |
a84956e7ee4d
8170987: Module system implementation refresh (12/2016)
alanb
parents:
40599
diff
changeset
|
685 |
String dependency = i > 0 ? "requires m" + (i - 1) + "x;" : ""; |
51615
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
686 |
Path dir = base.resolve(paths[i]); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
687 |
if (useModuleSubdirs) { |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
688 |
dir = dir.resolve(moduleName); |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
689 |
} |
afbb33428df7
8208608: Update --module-source-path to allow explicit source paths for specific modules
jjg
parents:
49822
diff
changeset
|
690 |
tb.writeJavaFiles(dir, |
36526 | 691 |
"module " + moduleName + " { " + dependency + " }", |
692 |
"package pkg" + i + "; class A { }"); |
|
693 |
} |
|
694 |
} |
|
695 |
||
696 |
private void checkFiles(Path... files) throws Exception { |
|
697 |
for (Path file : files) { |
|
698 |
if (!Files.exists(file)) { |
|
44690
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
699 |
throw new Exception("File not found: " + file); |
36526 | 700 |
} |
701 |
} |
|
702 |
} |
|
44690
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
703 |
|
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
704 |
private void checkLocation(Iterable<? extends Path> locn, List<Path> ref) throws Exception { |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
705 |
List<Path> list = asList(locn); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
706 |
if (!list.equals(ref)) { |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
707 |
out.println("expect: " + ref); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
708 |
out.println(" found: " + list); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
709 |
throw new Exception("location not as expected"); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
710 |
} |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
711 |
} |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
712 |
|
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
713 |
private <T> List<T> asList(Iterable<? extends T> iter) { |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
714 |
List<T> list = new ArrayList<>(); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
715 |
for (T item : iter) { |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
716 |
list.add(item); |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
717 |
} |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
718 |
return list; |
aec722d1b538
8178509: MODULE_SOURCE_PATH: Implement missing methods
jjg
parents:
42822
diff
changeset
|
719 |
} |
36526 | 720 |
} |