author | pli |
Tue, 16 Jul 2019 00:57:00 +0000 | |
changeset 55689 | 8c5c9d86e1d6 |
parent 47216 | 71c04702a3d5 |
child 57540 | dd6d424909dc |
permissions | -rw-r--r-- |
40513
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
1 |
/* |
55689
8c5c9d86e1d6
8227512: [TESTBUG] Fix JTReg javac test failures with Graal
pli
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
40513
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
4 |
* |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
8 |
* |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
13 |
* accompanied this code). |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
14 |
* |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
18 |
* |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
21 |
* questions. |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
22 |
*/ |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
23 |
|
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
24 |
/** |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
25 |
* @test |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
26 |
* @bug 8153391 |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
27 |
* @summary Verify javac behaves properly in absence of zip/jar FileSystemProvider |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
28 |
* @library /tools/lib |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
29 |
* @modules jdk.compiler/com.sun.tools.javac.api |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
30 |
* jdk.compiler/com.sun.tools.javac.main |
55689
8c5c9d86e1d6
8227512: [TESTBUG] Fix JTReg javac test failures with Graal
pli
parents:
47216
diff
changeset
|
31 |
* @run main/othervm --limit-modules jdk.compiler,jdk.internal.vm.compiler LimitedImage |
40513
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
32 |
*/ |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
33 |
|
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
34 |
import java.io.IOException; |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
35 |
import java.nio.file.Path; |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
36 |
import java.nio.file.Paths; |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
37 |
import java.util.Arrays; |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
38 |
import java.util.List; |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
39 |
|
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
40 |
import toolbox.JavacTask; |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
41 |
import toolbox.JarTask; |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
42 |
import toolbox.Task.Expect; |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
43 |
import toolbox.Task.Mode; |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
44 |
import toolbox.Task.OutputKind; |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
45 |
import toolbox.ToolBox; |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
46 |
|
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
47 |
public class LimitedImage { |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
48 |
public static void main(String... args) throws IOException { |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
49 |
ToolBox tb = new ToolBox(); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
50 |
|
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
51 |
//showing help should be OK |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
52 |
new JavacTask(tb, Mode.CMDLINE) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
53 |
.options("--help") |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
54 |
.run().writeAll(); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
55 |
|
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
56 |
Path testSource = Paths.get("Test.java"); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
57 |
tb.writeFile(testSource, "class Test {}"); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
58 |
|
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
59 |
//when zip/jar FS is not needed, compilation should succeed |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
60 |
new JavacTask(tb, Mode.CMDLINE) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
61 |
.classpath() |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
62 |
.files(testSource) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
63 |
.outdir(".") |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
64 |
.run() |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
65 |
.writeAll(); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
66 |
|
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
67 |
Path testJar = Paths.get("test.jar").toAbsolutePath(); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
68 |
|
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
69 |
new JarTask(tb, testJar).run(); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
70 |
|
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
71 |
List<String> actualOutput; |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
72 |
List<String> expectedOutput = Arrays.asList( |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
73 |
"- compiler.err.no.zipfs.for.archive: " + testJar.toString() |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
74 |
); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
75 |
|
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
76 |
//check proper diagnostics when zip/jar FS not present: |
43574
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
40599
diff
changeset
|
77 |
System.err.println("Test " + testJar + " on classpath"); |
40513
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
78 |
actualOutput = new JavacTask(tb, Mode.CMDLINE) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
79 |
.classpath(testJar) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
80 |
.options("-XDrawDiagnostics") |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
81 |
.files(testSource) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
82 |
.outdir(".") |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
83 |
.run(Expect.FAIL) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
84 |
.writeAll() |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
85 |
.getOutputLines(OutputKind.DIRECT); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
86 |
|
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
87 |
if (!expectedOutput.equals(actualOutput)) { |
43574
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
40599
diff
changeset
|
88 |
throw new AssertionError("Unexpected output"); |
40513
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
89 |
} |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
90 |
|
43574
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
40599
diff
changeset
|
91 |
System.err.println("Test " + testJar + " on sourcepath"); |
40513
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
92 |
actualOutput = new JavacTask(tb, Mode.CMDLINE) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
93 |
.sourcepath(testJar) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
94 |
.options("-XDrawDiagnostics") |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
95 |
.files(testSource) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
96 |
.outdir(".") |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
97 |
.run(Expect.FAIL) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
98 |
.writeAll() |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
99 |
.getOutputLines(OutputKind.DIRECT); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
100 |
|
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
101 |
if (!expectedOutput.equals(actualOutput)) { |
43574
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
40599
diff
changeset
|
102 |
throw new AssertionError("Unexpected output"); |
40513
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
103 |
} |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
104 |
|
43574
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
40599
diff
changeset
|
105 |
System.err.println("Test " + testJar + " on modulepath"); |
40513
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
106 |
actualOutput = new JavacTask(tb, Mode.CMDLINE) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
107 |
.options("-XDrawDiagnostics", |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
108 |
"--module-path", testJar.toString()) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
109 |
.files(testSource) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
110 |
.outdir(".") |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
111 |
.run(Expect.FAIL) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
112 |
.writeAll() |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
113 |
.getOutputLines(OutputKind.DIRECT); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
114 |
|
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
115 |
if (!expectedOutput.equals(actualOutput)) { |
43574
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
40599
diff
changeset
|
116 |
throw new AssertionError("Unexpected output"); |
40513
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
117 |
} |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
118 |
|
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
119 |
expectedOutput = Arrays.asList( |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
120 |
"- compiler.err.no.zipfs.for.archive: " + testJar.toString(), |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
121 |
"1 error" |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
122 |
); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
123 |
|
43574
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
40599
diff
changeset
|
124 |
System.err.println("Test directory containing " + testJar + " on modulepath"); |
40513
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
125 |
actualOutput = new JavacTask(tb, Mode.CMDLINE) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
126 |
.classpath() |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
127 |
.options("-XDrawDiagnostics", |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
128 |
"--module-path", testJar.getParent().toString()) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
129 |
.files(testSource) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
130 |
.outdir(".") |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
131 |
.run(Expect.FAIL) |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
132 |
.writeAll() |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
133 |
.getOutputLines(OutputKind.DIRECT); |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
134 |
|
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
135 |
if (!expectedOutput.equals(actualOutput)) { |
43574
042e694725f7
8166675: Latent bug in jar file handling during module path processing.
jjg
parents:
40599
diff
changeset
|
136 |
throw new AssertionError("Unexpected output"); |
40513
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
137 |
} |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
138 |
} |
39b67170b045
8153391: an image created for \"jdk.compiler\" fails to run javac
jlahoda
parents:
diff
changeset
|
139 |
|
40599
be40838eb215
8164887: update tests to remove use of old-style options
jjg
parents:
40513
diff
changeset
|
140 |
} |