author | jlahoda |
Wed, 13 Jun 2018 12:52:21 +0200 | |
changeset 50539 | 7bf4f1b5e438 |
parent 49579 | fce4252d5227 |
permissions | -rw-r--r-- |
43138
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
1 |
/* |
43272
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
2 |
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. |
43138
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
4 |
* |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
8 |
* |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
13 |
* accompanied this code). |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
14 |
* |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
18 |
* |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
21 |
* questions. |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
22 |
*/ |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
23 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
24 |
/* |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
25 |
* @test |
50539
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
26 |
* @bug 8169197 8172668 8173117 8175007 8189765 8193302 |
43138
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
27 |
* @summary Check convenient errors are produced for inaccessible classes. |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
28 |
* @library /tools/lib |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
29 |
* @modules jdk.compiler/com.sun.tools.javac.api |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
30 |
* jdk.compiler/com.sun.tools.javac.main |
43272
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
31 |
* jdk.compiler/com.sun.tools.javac.util |
43138
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
32 |
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask ModuleTestBase |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
33 |
* @run main ConvenientAccessErrorsTest |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
34 |
*/ |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
35 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
36 |
import java.nio.file.Files; |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
37 |
import java.nio.file.Path; |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
38 |
import java.util.Arrays; |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
39 |
import java.util.List; |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
40 |
|
43272
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
41 |
import com.sun.tools.javac.util.Context; |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
42 |
import com.sun.tools.javac.util.Convert; |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
43 |
import com.sun.tools.javac.util.Name; |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
44 |
import com.sun.tools.javac.util.Names; |
43138
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
45 |
import toolbox.JarTask; |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
46 |
import toolbox.JavacTask; |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
47 |
import toolbox.Task; |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
48 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
49 |
public class ConvenientAccessErrorsTest extends ModuleTestBase { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
50 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
51 |
public static void main(String... args) throws Exception { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
52 |
new ConvenientAccessErrorsTest().runTests(); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
53 |
} |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
54 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
55 |
@Test |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
56 |
public void testNoDep(Path base) throws Exception { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
57 |
Path src = base.resolve("src"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
58 |
Path src_m1 = src.resolve("m1x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
59 |
tb.writeJavaFiles(src_m1, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
60 |
"module m1x { exports api; }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
61 |
"package api; public class Api { public void call() { } }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
62 |
Path src_m2 = src.resolve("m2x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
63 |
tb.writeJavaFiles(src_m2, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
64 |
"module m2x { }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
65 |
"package test; public class Test { api.Api api; }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
66 |
Path classes = base.resolve("classes"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
67 |
tb.createDirectories(classes); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
68 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
69 |
List<String> log = new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
70 |
.options("-XDrawDiagnostics", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
71 |
"--module-source-path", src.toString()) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
72 |
.outdir(classes) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
73 |
.files(findJavaFiles(src)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
74 |
.run(Task.Expect.FAIL) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
75 |
.writeAll() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
76 |
.getOutputLines(Task.OutputKind.DIRECT); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
77 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
78 |
List<String> expected = Arrays.asList( |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
79 |
"Test.java:1:35: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read: m2x, api, m1x)", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
80 |
"1 error"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
81 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
82 |
if (!expected.equals(log)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
83 |
throw new Exception("expected output not found; actual: " + log); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
84 |
} |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
85 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
86 |
@Test |
43272
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
87 |
public void testNoDepNested(Path base) throws Exception { |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
88 |
Path src = base.resolve("src"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
89 |
Path src_m1 = src.resolve("m1x"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
90 |
tb.writeJavaFiles(src_m1, |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
91 |
"module m1x { exports api; }", |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
92 |
"package api; public class Api { public static class Nested {} }"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
93 |
Path src_m2 = src.resolve("m2x"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
94 |
tb.writeJavaFiles(src_m2, |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
95 |
"module m2x { }", |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
96 |
"package test; public class Test { api.Api.Nested nested; }"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
97 |
Path classes = base.resolve("classes"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
98 |
tb.createDirectories(classes); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
99 |
|
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
100 |
List<String> log = new JavacTask(tb) |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
101 |
.options("-XDrawDiagnostics", |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
102 |
"--module-source-path", src.toString()) |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
103 |
.outdir(classes) |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
104 |
.files(findJavaFiles(src)) |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
105 |
.run(Task.Expect.FAIL) |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
106 |
.writeAll() |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
107 |
.getOutputLines(Task.OutputKind.DIRECT); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
108 |
|
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
109 |
List<String> expected = Arrays.asList( |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
110 |
"Test.java:1:35: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read: m2x, api, m1x)", |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
111 |
"1 error"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
112 |
|
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
113 |
if (!expected.equals(log)) |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
114 |
throw new Exception("expected output not found; actual: " + log); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
115 |
} |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
116 |
|
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
117 |
@Test |
43138
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
118 |
public void testNotExported(Path base) throws Exception { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
119 |
Path src = base.resolve("src"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
120 |
Path src_m1 = src.resolve("m1x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
121 |
tb.writeJavaFiles(src_m1, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
122 |
"module m1x { exports api; }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
123 |
"package api; public class Api { }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
124 |
"package impl; public class Impl { }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
125 |
Path src_m2 = src.resolve("m2x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
126 |
tb.writeJavaFiles(src_m2, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
127 |
"module m2x { requires m1x; }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
128 |
"package test; public class Test { impl.Impl api; }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
129 |
Path src_m3 = src.resolve("m3x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
130 |
tb.writeJavaFiles(src_m3, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
131 |
"module m3x { requires m1x; }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
132 |
Path classes = base.resolve("classes"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
133 |
tb.createDirectories(classes); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
134 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
135 |
List<String> log = new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
136 |
.options("-XDrawDiagnostics", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
137 |
"--module-source-path", src.toString()) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
138 |
.outdir(classes) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
139 |
.files(findJavaFiles(src)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
140 |
.run(Task.Expect.FAIL) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
141 |
.writeAll() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
142 |
.getOutputLines(Task.OutputKind.DIRECT); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
143 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
144 |
List<String> expected = Arrays.asList( |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
145 |
"Test.java:1:35: compiler.err.package.not.visible: impl, (compiler.misc.not.def.access.not.exported: impl, m1x)", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
146 |
"1 error"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
147 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
148 |
if (!expected.equals(log)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
149 |
throw new Exception("expected output not found; actual: " + log); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
150 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
151 |
tb.writeJavaFiles(src_m1, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
152 |
"module m1x { exports api; exports impl to m3x;}"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
153 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
154 |
log = new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
155 |
.options("-XDrawDiagnostics", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
156 |
"--module-source-path", src.toString()) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
157 |
.outdir(classes) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
158 |
.files(findJavaFiles(src)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
159 |
.run(Task.Expect.FAIL) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
160 |
.writeAll() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
161 |
.getOutputLines(Task.OutputKind.DIRECT); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
162 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
163 |
expected = Arrays.asList( |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
164 |
"Test.java:1:35: compiler.err.package.not.visible: impl, (compiler.misc.not.def.access.not.exported.to.module: impl, m1x, m2x)", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
165 |
"1 error"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
166 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
167 |
if (!expected.equals(log)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
168 |
throw new Exception("expected output not found; actual: " + log); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
169 |
} |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
170 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
171 |
@Test |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
172 |
public void testInaccessibleInExported(Path base) throws Exception { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
173 |
Path src = base.resolve("src"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
174 |
Path src_m1 = src.resolve("m1x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
175 |
tb.writeJavaFiles(src_m1, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
176 |
"module m1x { exports api; }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
177 |
"package api; class Api { }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
178 |
Path src_m2 = src.resolve("m2x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
179 |
tb.writeJavaFiles(src_m2, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
180 |
"module m2x { requires m1x; }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
181 |
"package test; public class Test { api.Api api; }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
182 |
Path classes = base.resolve("classes"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
183 |
tb.createDirectories(classes); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
184 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
185 |
List<String> log = new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
186 |
.options("-XDrawDiagnostics", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
187 |
"--module-source-path", src.toString()) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
188 |
.outdir(classes) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
189 |
.files(findJavaFiles(src)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
190 |
.run(Task.Expect.FAIL) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
191 |
.writeAll() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
192 |
.getOutputLines(Task.OutputKind.DIRECT); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
193 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
194 |
List<String> expected = Arrays.asList( |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
195 |
"Test.java:1:38: compiler.err.not.def.public.cant.access: api.Api, api", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
196 |
"1 error"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
197 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
198 |
if (!expected.equals(log)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
199 |
throw new Exception("expected output not found; actual: " + log); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
200 |
} |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
201 |
|
49579
fce4252d5227
8189765: Improve error reporting for compiling against package not visible due to modules
jlahoda
parents:
47216
diff
changeset
|
202 |
@Test |
43138
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
203 |
public void testInaccessibleUnnamedModule(Path base) throws Exception { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
204 |
Path jar = prepareTestJar(base, "package api; class Api { public static class Foo {} }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
205 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
206 |
Path moduleSrc = base.resolve("module-src"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
207 |
Path m1x = moduleSrc.resolve("m1x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
208 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
209 |
Path classes = base.resolve("classes"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
210 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
211 |
Files.createDirectories(classes); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
212 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
213 |
tb.writeJavaFiles(m1x, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
214 |
"module m1x { }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
215 |
"package test; public class Test { api.Api api; api.Api.Foo api; }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
216 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
217 |
List<String> log = new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
218 |
.options("-classpath", jar.toString(), |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
219 |
"-XDrawDiagnostics") |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
220 |
.outdir(classes) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
221 |
.files(findJavaFiles(moduleSrc)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
222 |
.run(Task.Expect.FAIL) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
223 |
.writeAll() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
224 |
.getOutputLines(Task.OutputKind.DIRECT); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
225 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
226 |
List<String> expected = Arrays.asList( |
49579
fce4252d5227
8189765: Improve error reporting for compiling against package not visible due to modules
jlahoda
parents:
47216
diff
changeset
|
227 |
"Test.java:1:35: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m1x)", |
fce4252d5227
8189765: Improve error reporting for compiling against package not visible due to modules
jlahoda
parents:
47216
diff
changeset
|
228 |
"Test.java:1:48: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m1x)", |
43138
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
229 |
"2 errors"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
230 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
231 |
if (!expected.equals(log)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
232 |
throw new Exception("expected output not found; actual: " + log); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
233 |
} |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
234 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
235 |
@Test |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
236 |
public void testIndirectReferenceToUnnamedModule(Path base) throws Exception { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
237 |
Path jar = prepareTestJar(base, "package api; public class Api { public void test() {} }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
238 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
239 |
Path moduleSrc = base.resolve("module-src"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
240 |
Path m1x = moduleSrc.resolve("m1x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
241 |
Path auxiliary = moduleSrc.resolve("auxiliary"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
242 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
243 |
Path classes = base.resolve("classes"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
244 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
245 |
Files.createDirectories(classes); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
246 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
247 |
tb.writeJavaFiles(m1x, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
248 |
"module m1x { requires auxiliary; }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
249 |
"package test; public class Test { { auxiliary.Auxiliary.get().test(); } }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
250 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
251 |
tb.writeJavaFiles(auxiliary, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
252 |
"module auxiliary { exports auxiliary; }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
253 |
"package auxiliary; public class Auxiliary { public static api.Api get() { return null; } }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
254 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
255 |
List<String> log = new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
256 |
.options("-classpath", jar.toString(), |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
257 |
"-XDrawDiagnostics", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
258 |
"--add-reads", "auxiliary=ALL-UNNAMED", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
259 |
"--module-source-path", moduleSrc.toString()) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
260 |
.outdir(classes) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
261 |
.files(findJavaFiles(moduleSrc)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
262 |
.run(Task.Expect.FAIL) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
263 |
.writeAll() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
264 |
.getOutputLines(Task.OutputKind.DIRECT); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
265 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
266 |
List<String> expected = Arrays.asList( |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
267 |
"Test.java:1:62: compiler.err.not.def.access.class.intf.cant.access.reason: test(), api.Api, api, (compiler.misc.not.def.access.does.not.read.unnamed: api, m1x)", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
268 |
"1 error"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
269 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
270 |
if (!expected.equals(log)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
271 |
throw new Exception("expected output not found; actual: " + log); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
272 |
} |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
273 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
274 |
private Path prepareTestJar(Path base, String code) throws Exception { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
275 |
Path legacySrc = base.resolve("legacy-src"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
276 |
tb.writeJavaFiles(legacySrc, code); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
277 |
Path legacyClasses = base.resolve("legacy-classes"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
278 |
Files.createDirectories(legacyClasses); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
279 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
280 |
String log = new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
281 |
.options() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
282 |
.outdir(legacyClasses) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
283 |
.files(findJavaFiles(legacySrc)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
284 |
.run() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
285 |
.writeAll() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
286 |
.getOutput(Task.OutputKind.DIRECT); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
287 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
288 |
if (!log.isEmpty()) { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
289 |
throw new Exception("unexpected output: " + log); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
290 |
} |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
291 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
292 |
Path lib = base.resolve("lib"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
293 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
294 |
Files.createDirectories(lib); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
295 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
296 |
Path jar = lib.resolve("test-api-1.0.jar"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
297 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
298 |
new JarTask(tb, jar) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
299 |
.baseDir(legacyClasses) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
300 |
.files("api/Api.class") |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
301 |
.run(); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
302 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
303 |
return jar; |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
304 |
} |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
305 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
306 |
@Test |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
307 |
public void testUnnamedModuleAccess(Path base) throws Exception { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
308 |
Path src = base.resolve("src"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
309 |
Path src_m1 = src.resolve("m1x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
310 |
tb.writeJavaFiles(src_m1, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
311 |
"module m1x { exports api to m2x; }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
312 |
"package api; class Api { }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
313 |
"package impl; class Impl { }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
314 |
Path src_m2 = src.resolve("m2x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
315 |
tb.writeJavaFiles(src_m2, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
316 |
"module m2x { requires m1x; }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
317 |
Path modulepath = base.resolve("modulepath"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
318 |
tb.createDirectories(modulepath); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
319 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
320 |
new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
321 |
.options("--module-source-path", src.toString()) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
322 |
.outdir(modulepath) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
323 |
.files(findJavaFiles(src)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
324 |
.run() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
325 |
.writeAll(); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
326 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
327 |
Path unnamedSrc = base.resolve("unnamedSrc"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
328 |
tb.writeJavaFiles(unnamedSrc, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
329 |
"public class Test { api.Api api; impl.Impl impl; }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
330 |
Path unnamedClasses = base.resolve("unnamed-classes"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
331 |
Files.createDirectories(unnamedClasses); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
332 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
333 |
List<String> log = new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
334 |
.options("--module-path", modulepath.toString(), |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
335 |
"-XDrawDiagnostics") |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
336 |
.outdir(unnamedClasses) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
337 |
.files(findJavaFiles(unnamedSrc)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
338 |
.run(Task.Expect.FAIL) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
339 |
.writeAll() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
340 |
.getOutputLines(Task.OutputKind.DIRECT); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
341 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
342 |
List<String> expected = Arrays.asList( |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
343 |
"Test.java:1:21: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read.from.unnamed: api, m1x)", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
344 |
"Test.java:1:34: compiler.err.package.not.visible: impl, (compiler.misc.not.def.access.does.not.read.from.unnamed: impl, m1x)", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
345 |
"2 errors" |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
346 |
); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
347 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
348 |
if (!expected.equals(log)) { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
349 |
throw new Exception("unexpected output: " + log); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
350 |
} |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
351 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
352 |
log = new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
353 |
.options("--module-path", modulepath.toString(), |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
354 |
"--add-modules", "m1x", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
355 |
"-XDrawDiagnostics") |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
356 |
.outdir(unnamedClasses) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
357 |
.files(findJavaFiles(unnamedSrc)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
358 |
.run(Task.Expect.FAIL) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
359 |
.writeAll() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
360 |
.getOutputLines(Task.OutputKind.DIRECT); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
361 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
362 |
expected = Arrays.asList( |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
363 |
"Test.java:1:21: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.not.exported.to.module.from.unnamed: api, m1x)", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
364 |
"Test.java:1:34: compiler.err.package.not.visible: impl, (compiler.misc.not.def.access.not.exported.from.unnamed: impl, m1x)", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
365 |
"2 errors" |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
366 |
); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
367 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
368 |
if (!expected.equals(log)) { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
369 |
throw new Exception("unexpected output: " + log); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
370 |
} |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
371 |
} |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
372 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
373 |
@Test |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
374 |
public void testInImport(Path base) throws Exception { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
375 |
Path src = base.resolve("src"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
376 |
Path src_m1 = src.resolve("m1x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
377 |
tb.writeJavaFiles(src_m1, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
378 |
"module m1x { }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
379 |
"package api; public class Api { public String test() { return null; } }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
380 |
Path src_m2 = src.resolve("m2x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
381 |
tb.writeJavaFiles(src_m2, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
382 |
"module m2x { requires m1x; }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
383 |
"package test; import api.Api; public class Test { Api api; { api.test().length(); } }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
384 |
Path classes = base.resolve("classes"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
385 |
tb.createDirectories(classes); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
386 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
387 |
List<String> log = new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
388 |
.options("-XDrawDiagnostics", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
389 |
"--module-source-path", src.toString()) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
390 |
.outdir(classes) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
391 |
.files(findJavaFiles(src)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
392 |
.run(Task.Expect.FAIL) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
393 |
.writeAll() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
394 |
.getOutputLines(Task.OutputKind.DIRECT); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
395 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
396 |
List<String> expected = Arrays.asList( |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
397 |
"Test.java:1:22: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.not.exported: api, m1x)", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
398 |
"1 error"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
399 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
400 |
if (!expected.equals(log)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
401 |
throw new Exception("expected output not found; actual: " + log); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
402 |
} |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
403 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
404 |
@Test |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
405 |
public void testInImportOnDemand(Path base) throws Exception { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
406 |
Path src = base.resolve("src"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
407 |
Path src_m1 = src.resolve("m1x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
408 |
tb.writeJavaFiles(src_m1, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
409 |
"module m1x { }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
410 |
"package api; public class Api { public String test() { return null; } }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
411 |
Path src_m2 = src.resolve("m2x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
412 |
tb.writeJavaFiles(src_m2, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
413 |
"module m2x { requires m1x; }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
414 |
"package test; import api.*; public class Test { Api api; { api.test().length(); } }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
415 |
Path classes = base.resolve("classes"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
416 |
tb.createDirectories(classes); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
417 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
418 |
List<String> log = new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
419 |
.options("-XDrawDiagnostics", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
420 |
"--module-source-path", src.toString()) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
421 |
.outdir(classes) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
422 |
.files(findJavaFiles(src)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
423 |
.run(Task.Expect.FAIL) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
424 |
.writeAll() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
425 |
.getOutputLines(Task.OutputKind.DIRECT); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
426 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
427 |
List<String> expected = Arrays.asList( |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
428 |
"Test.java:1:22: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.not.exported: api, m1x)", |
43272
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
429 |
"1 error"); |
43138
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
430 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
431 |
if (!expected.equals(log)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
432 |
throw new Exception("expected output not found; actual: " + log); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
433 |
} |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
434 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
435 |
@Test |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
436 |
public void testUnusedImportOnDemand2(Path base) throws Exception { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
437 |
Path src = base.resolve("src"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
438 |
Path src_m1 = src.resolve("m1x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
439 |
tb.writeJavaFiles(src_m1, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
440 |
"module m1x { }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
441 |
"package api; public class Api { }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
442 |
Path src_m2 = src.resolve("m2x"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
443 |
tb.writeJavaFiles(src_m2, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
444 |
"module m2x { requires m1x; }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
445 |
"package test; import api.*; public class Test { }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
446 |
Path classes = base.resolve("classes"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
447 |
tb.createDirectories(classes); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
448 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
449 |
List<String> log = new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
450 |
.options("-XDrawDiagnostics", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
451 |
"--module-source-path", src.toString()) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
452 |
.outdir(classes) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
453 |
.files(findJavaFiles(src)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
454 |
.run(Task.Expect.FAIL) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
455 |
.writeAll() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
456 |
.getOutputLines(Task.OutputKind.DIRECT); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
457 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
458 |
List<String> expected = Arrays.asList( |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
459 |
"Test.java:1:22: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.not.exported: api, m1x)", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
460 |
"1 error"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
461 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
462 |
if (!expected.equals(log)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
463 |
throw new Exception("expected output not found; actual: " + log); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
464 |
} |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
465 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
466 |
@Test |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
467 |
public void testClassPackageConflict(Path base) throws Exception { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
468 |
Path libSrc = base.resolve("libSrc"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
469 |
tb.writeJavaFiles(libSrc, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
470 |
"package test.desktop; public class Any { }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
471 |
Path libClasses = base.resolve("libClasses"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
472 |
tb.createDirectories(libClasses); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
473 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
474 |
new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
475 |
.outdir(libClasses) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
476 |
.files(findJavaFiles(libSrc)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
477 |
.run() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
478 |
.writeAll() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
479 |
.getOutputLines(Task.OutputKind.DIRECT); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
480 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
481 |
Path src = base.resolve("src"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
482 |
tb.writeJavaFiles(src, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
483 |
"package test; public class desktop { public static class Action { } }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
484 |
"package use; import test.desktop.*; public class Use { test.desktop.Action a; }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
485 |
Path classes = base.resolve("classes"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
486 |
tb.createDirectories(classes); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
487 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
488 |
new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
489 |
.options("-XDrawDiagnostics") |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
490 |
.classpath(libClasses) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
491 |
.outdir(classes) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
492 |
.files(findJavaFiles(src)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
493 |
.run() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
494 |
.writeAll(); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
495 |
} |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
496 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
497 |
@Test |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
498 |
public void testClassPackageConflictInUnnamed(Path base) throws Exception { |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
499 |
Path libSrc = base.resolve("libSrc"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
500 |
tb.writeJavaFiles(libSrc, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
501 |
"package desktop; public class Any { }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
502 |
Path libClasses = base.resolve("libClasses"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
503 |
tb.createDirectories(libClasses); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
504 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
505 |
new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
506 |
.outdir(libClasses) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
507 |
.files(findJavaFiles(libSrc)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
508 |
.run() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
509 |
.writeAll() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
510 |
.getOutputLines(Task.OutputKind.DIRECT); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
511 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
512 |
Path src = base.resolve("src"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
513 |
tb.writeJavaFiles(src, |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
514 |
"public class desktop { public static class Action { } }", |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
515 |
"import desktop.*; public class Use { desktop.Action a; }"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
516 |
Path classes = base.resolve("classes"); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
517 |
tb.createDirectories(classes); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
518 |
|
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
519 |
new JavacTask(tb) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
520 |
.options("-XDrawDiagnostics") |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
521 |
.classpath(libClasses) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
522 |
.outdir(classes) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
523 |
.files(findJavaFiles(src)) |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
524 |
.run() |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
525 |
.writeAll(); |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
526 |
} |
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
527 |
|
43141
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
528 |
@Test |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
529 |
public void testUnresolvableInImport(Path base) throws Exception { |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
530 |
Path src = base.resolve("src"); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
531 |
Path src_m1 = src.resolve("m1x"); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
532 |
tb.writeJavaFiles(src_m1, |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
533 |
"module m1x { }", |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
534 |
"package api; import can.not.resolve; public class Api { }"); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
535 |
Path classes = base.resolve("classes"); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
536 |
tb.createDirectories(classes); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
537 |
|
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
538 |
List<String> log = new JavacTask(tb) |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
539 |
.options("-XDrawDiagnostics", |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
540 |
"--module-source-path", src.toString()) |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
541 |
.outdir(classes) |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
542 |
.files(findJavaFiles(src)) |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
543 |
.run(Task.Expect.FAIL) |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
544 |
.writeAll() |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
545 |
.getOutputLines(Task.OutputKind.DIRECT); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
546 |
|
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
547 |
List<String> expected = Arrays.asList( |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
548 |
"Api.java:1:28: compiler.err.doesnt.exist: can.not", |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
549 |
"1 error"); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
550 |
|
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
551 |
if (!expected.equals(log)) |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
552 |
throw new Exception("expected output not found; actual: " + log); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
553 |
} |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
554 |
|
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
555 |
@Test |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
556 |
public void testMissingKnownClass(Path base) throws Exception { |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
557 |
Path src = base.resolve("src"); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
558 |
Path src_m1 = src.resolve("m1x"); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
559 |
tb.writeJavaFiles(src_m1, |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
560 |
"module m1x { exports api; }", |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
561 |
"package api; public class Base { }", |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
562 |
"package api; public class Sub extends Base { }"); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
563 |
Path classes = base.resolve("classes"); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
564 |
tb.createDirectories(classes); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
565 |
Path m1xClasses = classes.resolve("m1x"); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
566 |
tb.createDirectories(m1xClasses); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
567 |
|
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
568 |
new JavacTask(tb) |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
569 |
.options("-XDrawDiagnostics") |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
570 |
.outdir(m1xClasses) |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
571 |
.files(findJavaFiles(src_m1)) |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
572 |
.run(Task.Expect.SUCCESS) |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
573 |
.writeAll(); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
574 |
|
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
575 |
Files.delete(m1xClasses.resolve("api").resolve("Base.class")); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
576 |
|
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
577 |
Path src_m2 = src.resolve("m2x"); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
578 |
tb.writeJavaFiles(src_m2, |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
579 |
"module m2x { requires m1x; }", |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
580 |
"package test;\n" + |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
581 |
"import api.Sub;\n" + |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
582 |
"import api.Base;\n" + |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
583 |
"public class Test {\n" + |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
584 |
" Sub a2;\n" + |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
585 |
" Base a;\n" + |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
586 |
"}\n"); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
587 |
Path m2xClasses = classes.resolve("m2x"); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
588 |
tb.createDirectories(m2xClasses); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
589 |
List<String> log = new JavacTask(tb) |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
590 |
.options("-XDrawDiagnostics", |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
591 |
"--module-path", classes.toString(), |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
592 |
"-XDdev") |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
593 |
.outdir(m2xClasses) |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
594 |
.files(findJavaFiles(src_m2)) |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
595 |
.run(Task.Expect.FAIL) |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
596 |
.writeAll() |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
597 |
.getOutputLines(Task.OutputKind.DIRECT); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
598 |
|
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
599 |
List<String> expected = Arrays.asList( |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
600 |
"Test.java:3:11: compiler.err.cant.resolve.location: kindname.class, Base, , , (compiler.misc.location: kindname.package, api, null)", |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
601 |
"Test.java:6:5: compiler.err.cant.resolve.location: kindname.class, Base, , , (compiler.misc.location: kindname.class, test.Test, null)", |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
602 |
"2 errors"); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
603 |
|
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
604 |
if (!expected.equals(log)) |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
605 |
throw new Exception("expected output not found; actual: " + log); |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
606 |
} |
7ea6578a9110
8172668: NPE in jdk.compiler/com.sun.tools.javac.comp.TypeEnter$ImportsPhase.importNamed(
jlahoda
parents:
43138
diff
changeset
|
607 |
|
43272
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
608 |
@Test |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
609 |
public void testInaccessibleInSourceModuleViaBinaryModule(Path base) throws Exception { |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
610 |
Path src = base.resolve("src"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
611 |
Path src_m1 = src.resolve("m1x"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
612 |
tb.writeJavaFiles(src_m1, |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
613 |
"@Deprecated module m1x { }"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
614 |
Path src_m2 = src.resolve("m2x"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
615 |
tb.writeJavaFiles(src_m2, |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
616 |
"module m2x { requires transitive m1x; }"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
617 |
Path src_m3 = src.resolve("m3x"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
618 |
tb.writeJavaFiles(src_m3, |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
619 |
"module m3x { requires transitive m2x; exports api; }", |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
620 |
"package api; class Api { }"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
621 |
Path classes = base.resolve("classes"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
622 |
tb.createDirectories(classes); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
623 |
|
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
624 |
new JavacTask(tb) |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
625 |
.options("-XDrawDiagnostics", |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
626 |
"--module-source-path", src.toString()) |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
627 |
.outdir(classes) |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
628 |
.files(findJavaFiles(src)) |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
629 |
.run() |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
630 |
.writeAll(); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
631 |
|
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
632 |
tb.cleanDirectory(classes.resolve("m2x")); //force completion from source if needed |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
633 |
Files.delete(classes.resolve("m2x")); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
634 |
|
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
635 |
tb.cleanDirectory(src_m3); //binary only module |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
636 |
Files.delete(src_m3); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
637 |
|
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
638 |
//m4x does not depend on m1x/m2x/m3x, so cannot access api.Api |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
639 |
//but the recovery search should not complete m2x, as that would cause a deprecation warning: |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
640 |
Path src_m4 = src.resolve("m4x"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
641 |
tb.writeJavaFiles(src_m4, |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
642 |
"module m4x { }", |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
643 |
"package m4x; public class Test extends api.Api { }"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
644 |
|
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
645 |
List<String> log = new JavacTask(tb) |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
646 |
.options("-XDrawDiagnostics", |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
647 |
"--module-source-path", src.toString(), |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
648 |
"--module-path", classes.toString(), |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
649 |
"-Xlint:deprecation") |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
650 |
.outdir(classes) |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
651 |
.files(findJavaFiles(src_m4)) |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
652 |
.run(Task.Expect.FAIL) |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
653 |
.writeAll() |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
654 |
.getOutputLines(Task.OutputKind.DIRECT); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
655 |
|
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
656 |
List<String> expected = Arrays.asList( |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
657 |
"Test.java:1:40: compiler.err.package.not.visible: api, (compiler.misc.not.def.access.does.not.read: m4x, api, m3x)", |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
658 |
"1 error"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
659 |
|
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
660 |
if (!expected.equals(log)) |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
661 |
throw new Exception("expected output not found; actual: " + log); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
662 |
} |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
663 |
|
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
664 |
@Test |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
665 |
public void testConvertNameCandidates(Path base) throws Exception { |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
666 |
Context ctx = new Context(); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
667 |
Names names = Names.instance(ctx); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
668 |
Name name = names.fromString("com.sun.tools.javac.Attr.BreakAttr"); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
669 |
|
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
670 |
com.sun.tools.javac.util.List<String> actual = |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
671 |
Convert.classCandidates(name).map(n -> n.toString()); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
672 |
List<String> expected = Arrays.asList( |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
673 |
"com.sun$tools$javac$Attr$BreakAttr", |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
674 |
"com.sun.tools$javac$Attr$BreakAttr", |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
675 |
"com.sun.tools.javac$Attr$BreakAttr", |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
676 |
"com.sun.tools.javac.Attr$BreakAttr", |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
677 |
"com.sun.tools.javac.Attr.BreakAttr" |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
678 |
); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
679 |
|
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
680 |
if (!expected.equals(actual)) { |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
681 |
throw new Exception("Expected names not generated: " + actual); |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
682 |
} |
421ae1e38d2d
8173117: Compilation significantly slower after JDK-8169197
jlahoda
parents:
43141
diff
changeset
|
683 |
} |
43866
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
684 |
|
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
685 |
@Test |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
686 |
public void testInaccessibleInVisible(Path base) throws Exception { |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
687 |
Path src = base.resolve("src"); |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
688 |
Path src_ma = src.resolve("ma"); |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
689 |
tb.writeJavaFiles(src_ma, |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
690 |
"module ma { exports ma; }", |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
691 |
"package ma; class NotApi { public static class Inner { } }"); |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
692 |
Path classes = base.resolve("classes"); |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
693 |
tb.createDirectories(classes); |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
694 |
|
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
695 |
new JavacTask(tb) |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
696 |
.outdir(classes) |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
697 |
.files(findJavaFiles(src_ma)) |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
698 |
.run() |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
699 |
.writeAll(); |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
700 |
|
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
701 |
Path src_mb = src.resolve("mb"); |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
702 |
tb.writeJavaFiles(src_mb, |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
703 |
"module mb { requires ma; }", |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
704 |
"package mb.a; public class Test { ma.NotApi.Inner i1; mb.b.NotApi.Inner i2; }", |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
705 |
"package mb.b; class NotApi { public static class Inner { } }"); |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
706 |
|
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
707 |
List<String> log = new JavacTask(tb) |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
708 |
.options("-XDrawDiagnostics", |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
709 |
"--module-path", classes.toString()) |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
710 |
.outdir(classes) |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
711 |
.files(findJavaFiles(src_mb)) |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
712 |
.run(Task.Expect.FAIL) |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
713 |
.writeAll() |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
714 |
.getOutputLines(Task.OutputKind.DIRECT); |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
715 |
|
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
716 |
List<String> expected = Arrays.asList( |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
717 |
"Test.java:1:44: compiler.err.not.def.access.class.intf.cant.access: ma.NotApi.Inner, ma.NotApi", |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
718 |
"Test.java:1:66: compiler.err.not.def.access.class.intf.cant.access: mb.b.NotApi.Inner, mb.b.NotApi", |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
719 |
"2 errors"); |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
720 |
|
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
721 |
if (!expected.equals(log)) |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
722 |
throw new Exception("expected output not found; actual: " + log); |
3195ea126044
8175007: Incorrect error messages for inaccessible classes in visible packages
jlahoda
parents:
43272
diff
changeset
|
723 |
} |
50539
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
724 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
725 |
@Test |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
726 |
public void testPackagesUniquelyVisibleInImportOnDemand(Path base) throws Exception { |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
727 |
Path src = base.resolve("src"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
728 |
Path src_ma = src.resolve("ma"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
729 |
tb.writeJavaFiles(src_ma, |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
730 |
"module ma { exports ma; }", |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
731 |
"package ma; public class Api { }"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
732 |
Path src_mb = src.resolve("mb"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
733 |
tb.writeJavaFiles(src_mb, |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
734 |
"module mb { exports ma.mb; }", |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
735 |
"package ma.mb; public class Api { }"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
736 |
Path classes = base.resolve("classes"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
737 |
tb.createDirectories(classes); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
738 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
739 |
new JavacTask(tb) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
740 |
.options("--module-source-path", src.toString()) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
741 |
.outdir(classes) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
742 |
.files(findJavaFiles(src)) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
743 |
.run() |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
744 |
.writeAll(); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
745 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
746 |
Path test = src.resolve("test"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
747 |
tb.writeJavaFiles(test, |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
748 |
"module test { requires mb; }", |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
749 |
"package test; import ma.*; public class Test { }"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
750 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
751 |
List<String> log = new JavacTask(tb) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
752 |
.options("-XDrawDiagnostics", |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
753 |
"--module-path", classes.toString()) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
754 |
.outdir(classes) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
755 |
.files(findJavaFiles(test)) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
756 |
.run(Task.Expect.FAIL) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
757 |
.writeAll() |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
758 |
.getOutputLines(Task.OutputKind.DIRECT); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
759 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
760 |
List<String> expected = Arrays.asList( |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
761 |
"Test.java:1:22: compiler.err.package.not.visible: ma, (compiler.misc.not.def.access.does.not.read: test, ma, ma)", |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
762 |
"1 error"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
763 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
764 |
if (!expected.equals(log)) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
765 |
throw new Exception("expected output not found; actual: " + log); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
766 |
} |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
767 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
768 |
@Test |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
769 |
public void testPackagesUniquelyVisibleInImportOnDemandNoPrefixes(Path base) throws Exception { |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
770 |
Path src = base.resolve("src"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
771 |
Path src_mb = src.resolve("mb"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
772 |
tb.writeJavaFiles(src_mb, |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
773 |
"module mb { exports ma.mb; }", |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
774 |
"package ma.mb; public class Api { }"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
775 |
Path classes = base.resolve("classes"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
776 |
tb.createDirectories(classes); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
777 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
778 |
new JavacTask(tb) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
779 |
.options("--module-source-path", src.toString()) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
780 |
.outdir(classes) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
781 |
.files(findJavaFiles(src)) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
782 |
.run() |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
783 |
.writeAll(); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
784 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
785 |
Path test = src.resolve("test"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
786 |
tb.writeJavaFiles(test, |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
787 |
"module test { requires mb; }", |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
788 |
"package test; import ma.mb.*; import ma.*; public class Test { }"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
789 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
790 |
List<String> log = new JavacTask(tb) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
791 |
.options("-XDrawDiagnostics", |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
792 |
"--module-path", classes.toString()) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
793 |
.outdir(classes) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
794 |
.files(findJavaFiles(test)) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
795 |
.run(Task.Expect.FAIL) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
796 |
.writeAll() |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
797 |
.getOutputLines(Task.OutputKind.DIRECT); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
798 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
799 |
List<String> expected = Arrays.asList( |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
800 |
"Test.java:1:31: compiler.err.doesnt.exist: ma", |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
801 |
"1 error"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
802 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
803 |
if (!expected.equals(log)) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
804 |
throw new Exception("expected output not found; actual: " + log); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
805 |
} |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
806 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
807 |
@Test |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
808 |
public void testPackagesUniquelyVisibleInImportOnDemandThisModule(Path base) throws Exception { |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
809 |
Path src = base.resolve("src"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
810 |
Path test = src.resolve("test"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
811 |
tb.writeJavaFiles(test, |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
812 |
"module test { }", |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
813 |
"package ma.mb; public class Impl { }", |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
814 |
"package test; import ma.*; public class Test { }"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
815 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
816 |
Path classes = base.resolve("classes"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
817 |
tb.createDirectories(classes); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
818 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
819 |
List<String> log = new JavacTask(tb) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
820 |
.options("-XDrawDiagnostics") |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
821 |
.outdir(classes) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
822 |
.files(findJavaFiles(test)) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
823 |
.run(Task.Expect.FAIL) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
824 |
.writeAll() |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
825 |
.getOutputLines(Task.OutputKind.DIRECT); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
826 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
827 |
List<String> expected = Arrays.asList( |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
828 |
"Test.java:1:15: compiler.err.doesnt.exist: ma", |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
829 |
"1 error"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
830 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
831 |
if (!expected.equals(log)) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
832 |
throw new Exception("expected output not found; actual: " + log); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
833 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
834 |
new JavacTask(tb) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
835 |
.options("-source", "8") |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
836 |
.outdir(classes) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
837 |
.files(findJavaFiles(test.resolve("ma"), test.resolve("test"))) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
838 |
.run(Task.Expect.SUCCESS) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
839 |
.writeAll(); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
840 |
} |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
841 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
842 |
@Test |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
843 |
public void testPackagesUniquelyVisibleInImportOnDemandThisModuleUnnamed(Path base) throws Exception { |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
844 |
Path src = base.resolve("src"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
845 |
Path test = src.resolve("test"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
846 |
tb.writeJavaFiles(test, |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
847 |
"package ma.mb; public class Impl { }", |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
848 |
"package test; import ma.*; public class Test { }"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
849 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
850 |
Path classes = base.resolve("classes"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
851 |
tb.createDirectories(classes); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
852 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
853 |
List<String> log = new JavacTask(tb) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
854 |
.options("-XDrawDiagnostics") |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
855 |
.outdir(classes) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
856 |
.files(findJavaFiles(test)) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
857 |
.run(Task.Expect.FAIL) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
858 |
.writeAll() |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
859 |
.getOutputLines(Task.OutputKind.DIRECT); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
860 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
861 |
List<String> expected = Arrays.asList( |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
862 |
"Test.java:1:15: compiler.err.doesnt.exist: ma", |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
863 |
"1 error"); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
864 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
865 |
if (!expected.equals(log)) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
866 |
throw new Exception("expected output not found; actual: " + log); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
867 |
|
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
868 |
new JavacTask(tb) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
869 |
.options("-source", "8") |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
870 |
.outdir(classes) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
871 |
.files(findJavaFiles(test)) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
872 |
.run(Task.Expect.SUCCESS) |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
873 |
.writeAll(); |
7bf4f1b5e438
8193302: Javac AssertionError: typeSig ERROR on usage of @Generated
jlahoda
parents:
49579
diff
changeset
|
874 |
} |
43138
680d378b9d64
8169197: Improve error reporting for compiling against unexported package
jlahoda
parents:
diff
changeset
|
875 |
} |