author | sadayapalam |
Mon, 06 Feb 2017 18:14:51 +0530 | |
changeset 43584 | 63e67712246b |
parent 43579 | 0d00f3ea77bc |
permissions | -rw-r--r-- |
43579
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
1 |
/* |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
4 |
* |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
8 |
* |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
13 |
* accompanied this code). |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
14 |
* |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
18 |
* |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
21 |
* questions. |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
22 |
*/ |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
23 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
24 |
/* |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
25 |
* @test |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
26 |
* @bug 8172240 |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
27 |
* @summary javac should not need the transitive closure to compile a module |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
28 |
* @library /tools/lib |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
29 |
* @modules |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
30 |
* jdk.compiler/com.sun.tools.javac.api |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
31 |
* jdk.compiler/com.sun.tools.javac.code |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
32 |
* jdk.compiler/com.sun.tools.javac.main |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
33 |
* jdk.compiler/com.sun.tools.javac.processing |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
34 |
* @build toolbox.ToolBox toolbox.JavacTask toolbox.ModuleBuilder ModuleTestBase |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
35 |
* @run main MissingModuleTest |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
36 |
*/ |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
37 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
38 |
import java.nio.file.Files; |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
39 |
import java.nio.file.Path; |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
40 |
import java.util.Arrays; |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
41 |
import java.util.List; |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
42 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
43 |
import toolbox.JavacTask; |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
44 |
import toolbox.Task; |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
45 |
import toolbox.Task.Expect; |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
46 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
47 |
public class MissingModuleTest extends ModuleTestBase { |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
48 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
49 |
public static void main(String... args) throws Exception { |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
50 |
new MissingModuleTest().runTests(); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
51 |
} |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
52 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
53 |
@Test |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
54 |
public void testMissingNotNeeded(Path base) throws Exception { |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
55 |
doTest(base, "m1x", new String[0]); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
56 |
} |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
57 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
58 |
@Test |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
59 |
public void testMissingNeededTransitive(Path base) throws Exception { |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
60 |
doTest(base, "m2x", "- compiler.err.module.not.found: m2x", "1 error"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
61 |
} |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
62 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
63 |
@Test |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
64 |
public void testMissingNeededDirect(Path base) throws Exception { |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
65 |
doTest(base, "m3x", "module-info.java:1:24: compiler.err.module.not.found: m3x", "1 error"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
66 |
} |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
67 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
68 |
@Test |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
69 |
public void testMultipleErrors(Path base) throws Exception { |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
70 |
doTest(base, "m4x", "module-info.java:1:38: compiler.err.module.not.found: m4x", "1 error"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
71 |
} |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
72 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
73 |
private void doTest(Path base, String toDelete, String... errors) throws Exception { |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
74 |
//note: avoiding use of java.base, as that gets special handling on some places: |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
75 |
Path srcMP = base.resolve("src-mp"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
76 |
Path m1x = srcMP.resolve("m1x"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
77 |
tb.writeJavaFiles(m1x, |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
78 |
"module m1x { exports api1; }", |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
79 |
"package api1; public interface Api { }"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
80 |
Path m2x = srcMP.resolve("m2x"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
81 |
tb.writeJavaFiles(m2x, |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
82 |
"module m2x { requires m1x; exports api2; }", |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
83 |
"package api2; public interface Api { }"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
84 |
Path m3x = srcMP.resolve("m3x"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
85 |
tb.writeJavaFiles(m3x, |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
86 |
"module m3x { requires transitive m2x; }"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
87 |
Path m4x = srcMP.resolve("m4x"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
88 |
tb.writeJavaFiles(m4x, |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
89 |
"module m4x { requires transitive m2x; }"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
90 |
Path m5x = srcMP.resolve("m5x"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
91 |
tb.writeJavaFiles(m5x, |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
92 |
"module m5x { requires transitive m4x; }"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
93 |
Path classesMP = base.resolve("classes-mp"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
94 |
tb.createDirectories(classesMP); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
95 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
96 |
new JavacTask(tb) |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
97 |
.options("--module-source-path", srcMP.toString()) |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
98 |
.outdir(classesMP) |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
99 |
.files(findJavaFiles(srcMP)) |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
100 |
.run() |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
101 |
.writeAll(); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
102 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
103 |
tb.cleanDirectory(classesMP.resolve(toDelete)); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
104 |
Files.delete(classesMP.resolve(toDelete)); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
105 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
106 |
Path src = base.resolve("src"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
107 |
tb.writeJavaFiles(src, |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
108 |
"module test { requires m3x; requires m4x; requires m5x; } "); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
109 |
Path classes = base.resolve("classes"); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
110 |
tb.createDirectories(classes); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
111 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
112 |
List<String> log = new JavacTask(tb) |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
113 |
.options("--module-path", classesMP.toString(), |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
114 |
"-XDrawDiagnostics") |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
115 |
.outdir(classes) |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
116 |
.files(findJavaFiles(src)) |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
117 |
.run(errors.length > 0 ? Expect.FAIL : Expect.SUCCESS) |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
118 |
.writeAll() |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
119 |
.getOutputLines(Task.OutputKind.DIRECT); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
120 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
121 |
if (errors.length == 0) { |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
122 |
errors = new String[] {""}; |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
123 |
} |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
124 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
125 |
if (!log.equals(Arrays.asList(errors))) |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
126 |
throw new Exception("expected output not found: " + log); |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
127 |
} |
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
128 |
|
0d00f3ea77bc
8172240: javac should not need the transitive closure to compile a module
vromero
parents:
diff
changeset
|
129 |
} |