author | jlahoda |
Wed, 02 Nov 2016 20:21:45 +0100 | |
changeset 41932 | b23b4712933b |
parent 41931 | d7c9720c4223 |
child 42407 | f3702cff2933 |
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 |
|
39366
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
26 |
* @bug 8155026 |
36526 | 27 |
* @summary Test automatic modules |
28 |
* @library /tools/lib |
|
29 |
* @modules |
|
39366
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
30 |
* java.desktop |
36526 | 31 |
* jdk.compiler/com.sun.tools.javac.api |
32 |
* jdk.compiler/com.sun.tools.javac.main |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
33 |
* @build toolbox.ToolBox toolbox.JavacTask toolbox.JarTask ModuleTestBase |
36526 | 34 |
* @run main AutomaticModules |
35 |
*/ |
|
36 |
||
37 |
import java.nio.file.Files; |
|
38 |
import java.nio.file.Path; |
|
39366
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
39 |
import java.util.Arrays; |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
40 |
import java.util.List; |
36526 | 41 |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
42 |
import toolbox.JarTask; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
43 |
import toolbox.JavacTask; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
44 |
import toolbox.Task; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
45 |
|
36526 | 46 |
public class AutomaticModules extends ModuleTestBase { |
47 |
||
48 |
public static void main(String... args) throws Exception { |
|
49 |
AutomaticModules t = new AutomaticModules(); |
|
50 |
t.runTests(); |
|
51 |
} |
|
52 |
||
53 |
@Test |
|
37758 | 54 |
public void testSimple(Path base) throws Exception { |
36526 | 55 |
Path legacySrc = base.resolve("legacy-src"); |
56 |
tb.writeJavaFiles(legacySrc, |
|
57 |
"package api; import java.awt.event.ActionListener; public abstract class Api implements ActionListener {}"); |
|
58 |
Path legacyClasses = base.resolve("legacy-classes"); |
|
59 |
Files.createDirectories(legacyClasses); |
|
60 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
61 |
String log = new JavacTask(tb) |
36526 | 62 |
.options() |
63 |
.outdir(legacyClasses) |
|
64 |
.files(findJavaFiles(legacySrc)) |
|
65 |
.run() |
|
66 |
.writeAll() |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
67 |
.getOutput(Task.OutputKind.DIRECT); |
36526 | 68 |
|
69 |
if (!log.isEmpty()) { |
|
70 |
throw new Exception("unexpected output: " + log); |
|
71 |
} |
|
72 |
||
73 |
Path modulePath = base.resolve("module-path"); |
|
74 |
||
75 |
Files.createDirectories(modulePath); |
|
76 |
||
77 |
Path jar = modulePath.resolve("test-api-1.0.jar"); |
|
78 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
79 |
new JarTask(tb, jar) |
36526 | 80 |
.baseDir(legacyClasses) |
81 |
.files("api/Api.class") |
|
82 |
.run(); |
|
83 |
||
84 |
Path moduleSrc = base.resolve("module-src"); |
|
85 |
Path m1 = moduleSrc.resolve("m1"); |
|
86 |
||
87 |
Path classes = base.resolve("classes"); |
|
88 |
||
89 |
Files.createDirectories(classes); |
|
90 |
||
91 |
tb.writeJavaFiles(m1, |
|
39366
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
92 |
"module m1 { requires test.api; requires java.desktop; }", |
36526 | 93 |
"package impl; public class Impl { public void e(api.Api api) { api.actionPerformed(null); } }"); |
94 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
95 |
new JavacTask(tb) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
39366
diff
changeset
|
96 |
.options("--module-source-path", moduleSrc.toString(), "--module-path", modulePath.toString()) |
36526 | 97 |
.outdir(classes) |
98 |
.files(findJavaFiles(moduleSrc)) |
|
99 |
.run() |
|
100 |
.writeAll(); |
|
101 |
} |
|
102 |
||
103 |
@Test |
|
37758 | 104 |
public void testUnnamedModule(Path base) throws Exception { |
36526 | 105 |
Path legacySrc = base.resolve("legacy-src"); |
106 |
tb.writeJavaFiles(legacySrc, |
|
107 |
"package api; public abstract class Api { public void run(CharSequence str) { } private void run(base.Base base) { } }", |
|
108 |
"package base; public interface Base { public void run(); }"); |
|
109 |
Path legacyClasses = base.resolve("legacy-classes"); |
|
110 |
Files.createDirectories(legacyClasses); |
|
111 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
112 |
String log = new JavacTask(tb) |
36526 | 113 |
.options() |
114 |
.outdir(legacyClasses) |
|
115 |
.files(findJavaFiles(legacySrc)) |
|
116 |
.run() |
|
117 |
.writeAll() |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
118 |
.getOutput(Task.OutputKind.DIRECT); |
36526 | 119 |
|
120 |
if (!log.isEmpty()) { |
|
121 |
throw new Exception("unexpected output: " + log); |
|
122 |
} |
|
123 |
||
124 |
Path modulePath = base.resolve("module-path"); |
|
125 |
||
126 |
Files.createDirectories(modulePath); |
|
127 |
||
128 |
Path apiJar = modulePath.resolve("test-api-1.0.jar"); |
|
129 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
130 |
new JarTask(tb, apiJar) |
36526 | 131 |
.baseDir(legacyClasses) |
132 |
.files("api/Api.class") |
|
133 |
.run(); |
|
134 |
||
135 |
Path baseJar = base.resolve("base.jar"); |
|
136 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
137 |
new JarTask(tb, baseJar) |
36526 | 138 |
.baseDir(legacyClasses) |
139 |
.files("base/Base.class") |
|
140 |
.run(); |
|
141 |
||
142 |
Path moduleSrc = base.resolve("module-src"); |
|
143 |
Path m1 = moduleSrc.resolve("m1"); |
|
144 |
||
145 |
Path classes = base.resolve("classes"); |
|
146 |
||
147 |
Files.createDirectories(classes); |
|
148 |
||
149 |
tb.writeJavaFiles(m1, |
|
150 |
"module m1 { requires test.api; }", |
|
151 |
"package impl; public class Impl { public void e(api.Api api) { api.run(\"\"); } }"); |
|
152 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
153 |
new JavacTask(tb) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
39366
diff
changeset
|
154 |
.options("--module-source-path", moduleSrc.toString(), "--module-path", modulePath.toString(), "--class-path", baseJar.toString()) |
36526 | 155 |
.outdir(classes) |
156 |
.files(findJavaFiles(moduleSrc)) |
|
157 |
.run() |
|
158 |
.writeAll(); |
|
159 |
} |
|
160 |
||
161 |
@Test |
|
37758 | 162 |
public void testModuleInfoFromClassFileDependsOnAutomatic(Path base) throws Exception { |
36526 | 163 |
Path automaticSrc = base.resolve("automaticSrc"); |
164 |
tb.writeJavaFiles(automaticSrc, "package api; public class Api {}"); |
|
165 |
Path automaticClasses = base.resolve("automaticClasses"); |
|
166 |
tb.createDirectories(automaticClasses); |
|
167 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
168 |
String automaticLog = new JavacTask(tb) |
36526 | 169 |
.outdir(automaticClasses) |
170 |
.files(findJavaFiles(automaticSrc)) |
|
171 |
.run() |
|
172 |
.writeAll() |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
173 |
.getOutput(Task.OutputKind.DIRECT); |
36526 | 174 |
|
175 |
if (!automaticLog.isEmpty()) |
|
176 |
throw new Exception("expected output not found: " + automaticLog); |
|
177 |
||
178 |
Path modulePath = base.resolve("module-path"); |
|
179 |
||
180 |
Files.createDirectories(modulePath); |
|
181 |
||
182 |
Path automaticJar = modulePath.resolve("automatic-1.0.jar"); |
|
183 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
184 |
new JarTask(tb, automaticJar) |
36526 | 185 |
.baseDir(automaticClasses) |
186 |
.files("api/Api.class") |
|
187 |
.run(); |
|
188 |
||
189 |
Path depSrc = base.resolve("depSrc"); |
|
190 |
Path depClasses = base.resolve("depClasses"); |
|
191 |
||
192 |
Files.createDirectories(depSrc); |
|
193 |
Files.createDirectories(depClasses); |
|
194 |
||
195 |
tb.writeJavaFiles(depSrc, |
|
196 |
"module m1 { requires public automatic; }", |
|
197 |
"package dep; public class Dep { api.Api api; }"); |
|
198 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
199 |
new JavacTask(tb) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
39366
diff
changeset
|
200 |
.options("--module-path", modulePath.toString()) |
36526 | 201 |
.outdir(depClasses) |
202 |
.files(findJavaFiles(depSrc)) |
|
203 |
.run() |
|
204 |
.writeAll(); |
|
205 |
||
206 |
Path moduleJar = modulePath.resolve("m1.jar"); |
|
207 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
208 |
new JarTask(tb, moduleJar) |
36526 | 209 |
.baseDir(depClasses) |
210 |
.files("module-info.class", "dep/Dep.class") |
|
211 |
.run(); |
|
212 |
||
213 |
Path testSrc = base.resolve("testSrc"); |
|
214 |
Path testClasses = base.resolve("testClasses"); |
|
215 |
||
216 |
Files.createDirectories(testSrc); |
|
217 |
Files.createDirectories(testClasses); |
|
218 |
||
219 |
tb.writeJavaFiles(testSrc, |
|
220 |
"module m2 { requires automatic; }", |
|
221 |
"package test; public class Test { }"); |
|
222 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
223 |
new JavacTask(tb) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
39366
diff
changeset
|
224 |
.options("--module-path", modulePath.toString()) |
36526 | 225 |
.outdir(testClasses) |
226 |
.files(findJavaFiles(testSrc)) |
|
227 |
.run() |
|
228 |
.writeAll(); |
|
229 |
} |
|
39366
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
230 |
|
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
231 |
@Test |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
232 |
public void testAutomaticAndNamedModules(Path base) throws Exception { |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
233 |
Path modulePath = base.resolve("module-path"); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
234 |
|
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
235 |
Files.createDirectories(modulePath); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
236 |
|
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
237 |
for (char c : new char[] {'A', 'B'}) { |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
238 |
Path automaticSrc = base.resolve("automaticSrc" + c); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
239 |
tb.writeJavaFiles(automaticSrc, "package api" + c + "; public class Api {}"); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
240 |
Path automaticClasses = base.resolve("automaticClasses" + c); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
241 |
tb.createDirectories(automaticClasses); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
242 |
|
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
243 |
String automaticLog = new JavacTask(tb) |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
244 |
.outdir(automaticClasses) |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
245 |
.files(findJavaFiles(automaticSrc)) |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
246 |
.run() |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
247 |
.writeAll() |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
248 |
.getOutput(Task.OutputKind.DIRECT); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
249 |
|
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
250 |
if (!automaticLog.isEmpty()) |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
251 |
throw new Exception("expected output not found: " + automaticLog); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
252 |
|
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
253 |
Path automaticJar = modulePath.resolve("automatic" + c + "-1.0.jar"); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
254 |
|
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
255 |
new JarTask(tb, automaticJar) |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
256 |
.baseDir(automaticClasses) |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
257 |
.files("api" + c + "/Api.class") |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
258 |
.run(); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
259 |
} |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
260 |
|
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
261 |
Path moduleSrc = base.resolve("module-src"); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
262 |
|
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
263 |
tb.writeJavaFiles(moduleSrc.resolve("m1"), |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
264 |
"module m1 { requires automaticA; }", |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
265 |
"package impl; public class Impl { apiA.Api a; apiB.Api b; m2.M2 m;}"); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
266 |
|
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
267 |
tb.writeJavaFiles(moduleSrc.resolve("m2"), |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
268 |
"module m2 { exports m2; }", |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
269 |
"package m2; public class M2 { }"); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
270 |
|
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
271 |
Path classes = base.resolve("classes"); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
272 |
|
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
273 |
Files.createDirectories(classes); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
274 |
|
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
275 |
List<String> log = new JavacTask(tb) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
39366
diff
changeset
|
276 |
.options("--module-source-path", moduleSrc.toString(), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
39366
diff
changeset
|
277 |
"--module-path", modulePath.toString(), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
39366
diff
changeset
|
278 |
"--add-modules", "automaticB", |
39366
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
279 |
"-XDrawDiagnostics") |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
280 |
.outdir(classes) |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
281 |
.files(findJavaFiles(moduleSrc)) |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
282 |
.run(Task.Expect.FAIL) |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
283 |
.writeAll() |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
284 |
.getOutputLines(Task.OutputKind.DIRECT); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
285 |
|
41932 | 286 |
List<String> expected = Arrays.asList("Impl.java:1:61: compiler.err.not.def.access.package.cant.access: m2.M2, m2", |
39366
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
287 |
"1 error"); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
288 |
|
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
289 |
if (!expected.equals(log)) { |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
290 |
throw new Exception("expected output not found: " + log); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
291 |
} |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
292 |
|
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
293 |
log = new JavacTask(tb) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
39366
diff
changeset
|
294 |
.options("--module-source-path", moduleSrc.toString(), |
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
39366
diff
changeset
|
295 |
"--module-path", modulePath.toString(), |
39366
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
296 |
"-XDrawDiagnostics") |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
297 |
.outdir(classes) |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
298 |
.files(findJavaFiles(moduleSrc)) |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
299 |
.run(Task.Expect.FAIL) |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
300 |
.writeAll() |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
301 |
.getOutputLines(Task.OutputKind.DIRECT); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
302 |
|
41932 | 303 |
expected = Arrays.asList("Impl.java:1:51: compiler.err.doesnt.exist: apiB", |
304 |
"Impl.java:1:61: compiler.err.not.def.access.package.cant.access: m2.M2, m2", |
|
39366
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
305 |
"2 errors"); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
306 |
|
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
307 |
if (!expected.equals(log)) { |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
308 |
throw new Exception("expected output not found: " + log); |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
309 |
} |
8bf5fe72ca88
8155026: javac grants implied readability to explicit modules
jlahoda
parents:
37758
diff
changeset
|
310 |
} |
36526 | 311 |
} |