author | lancea |
Fri, 12 Oct 2018 14:16:24 -0400 | |
changeset 52111 | 367b2cd49ec5 |
parent 51675 | b487c1e914d0 |
permissions | -rw-r--r-- |
36511 | 1 |
/* |
48841 | 2 |
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. |
36511 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/** |
|
25 |
* @test |
|
51675 | 26 |
* @library /test/lib |
52111
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
27 |
* @modules java.compiler |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
28 |
* jdk.compiler |
51675 | 29 |
* @build AddExportsTest jdk.test.lib.compiler.CompilerUtils |
36511 | 30 |
* @run testng AddExportsTest |
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
31 |
* @summary Basic tests for java --add-exports |
36511 | 32 |
*/ |
33 |
||
34 |
import java.nio.file.Path; |
|
35 |
import java.nio.file.Paths; |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
36 |
import java.util.stream.Stream; |
36511 | 37 |
|
45393 | 38 |
import jdk.test.lib.compiler.CompilerUtils; |
51675 | 39 |
import jdk.test.lib.process.OutputAnalyzer; |
40 |
import static jdk.test.lib.process.ProcessTools.*; |
|
36511 | 41 |
|
42 |
import org.testng.annotations.BeforeTest; |
|
43 |
import org.testng.annotations.DataProvider; |
|
44 |
import org.testng.annotations.Test; |
|
45 |
import static org.testng.Assert.*; |
|
46 |
||
47 |
||
48 |
@Test |
|
49 |
public class AddExportsTest { |
|
50 |
||
51 |
private static final String TEST_SRC = System.getProperty("test.src"); |
|
52 |
||
53 |
private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); |
|
54 |
private static final Path MODS_DIR = Paths.get("mods"); |
|
52111
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
55 |
private static final Path UPGRADE_MODS_DIRS = Paths.get("upgrademods"); |
36511 | 56 |
|
57 |
// test module m1 that uses Unsafe |
|
58 |
private static final String TEST1_MODULE = "m1"; |
|
59 |
private static final String TEST1_MAIN_CLASS = "jdk.test1.Main"; |
|
60 |
||
52111
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
61 |
// test module m2 uses java.compiler internals |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
62 |
private static final String TEST2_MODULE = "m2"; |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
63 |
private static final String TEST2_MAIN_CLASS = "jdk.test2.Main"; |
36511 | 64 |
|
65 |
// test module m3 uses m4 internals |
|
66 |
private static final String TEST3_MODULE = "m3"; |
|
67 |
private static final String TEST3_MAIN_CLASS = "jdk.test3.Main"; |
|
68 |
private static final String TEST4_MODULE = "m4"; |
|
69 |
||
70 |
||
71 |
@BeforeTest |
|
72 |
public void compileTestModules() throws Exception { |
|
73 |
||
74 |
// javac -d mods/m1 src/m1/** |
|
75 |
boolean compiled = CompilerUtils.compile( |
|
76 |
SRC_DIR.resolve(TEST1_MODULE), |
|
77 |
MODS_DIR.resolve(TEST1_MODULE), |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
78 |
"--add-exports", "java.base/jdk.internal.misc=m1"); |
36511 | 79 |
assertTrue(compiled, "module " + TEST1_MODULE + " did not compile"); |
80 |
||
52111
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
81 |
// javac -d upgrademods/java.compiler src/java.compiler/** |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
82 |
compiled = CompilerUtils.compile( |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
83 |
SRC_DIR.resolve("java.compiler"), |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
84 |
UPGRADE_MODS_DIRS.resolve("java.compiler")); |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
85 |
assertTrue(compiled, "module java.compiler did not compile"); |
36511 | 86 |
|
52111
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
87 |
// javac --upgrade-module-path upgrademods -d mods/m2 src/m2/** |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
88 |
compiled = CompilerUtils.compile( |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
89 |
SRC_DIR.resolve(TEST2_MODULE), |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
90 |
MODS_DIR.resolve(TEST2_MODULE), |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
91 |
"--upgrade-module-path", UPGRADE_MODS_DIRS.toString(), |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
92 |
"--add-exports", "java.compiler/javax.tools.internal=m2"); |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
93 |
assertTrue(compiled, "module " + TEST2_MODULE + " did not compile"); |
36511 | 94 |
|
95 |
// javac -d mods/m3 src/m3/** |
|
96 |
compiled = CompilerUtils.compile( |
|
97 |
SRC_DIR.resolve(TEST3_MODULE), |
|
98 |
MODS_DIR.resolve(TEST3_MODULE)); |
|
99 |
assertTrue(compiled, "module " + TEST3_MODULE + " did not compile"); |
|
100 |
||
101 |
// javac -d mods/m4 src/m4/** |
|
102 |
compiled = CompilerUtils.compile( |
|
103 |
SRC_DIR.resolve(TEST4_MODULE), |
|
104 |
MODS_DIR.resolve(TEST4_MODULE)); |
|
105 |
assertTrue(compiled, "module " + TEST4_MODULE + " did not compile"); |
|
106 |
} |
|
107 |
||
108 |
/** |
|
109 |
* Sanity check with -version |
|
110 |
*/ |
|
111 |
public void testSanity() throws Exception { |
|
112 |
||
113 |
int exitValue |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
114 |
= executeTestJava("--add-exports", "java.base/jdk.internal.reflect=ALL-UNNAMED", |
36511 | 115 |
"-version") |
116 |
.outputTo(System.out) |
|
117 |
.errorTo(System.out) |
|
118 |
.getExitValue(); |
|
119 |
||
120 |
assertTrue(exitValue == 0); |
|
121 |
} |
|
122 |
||
123 |
||
124 |
/** |
|
36966 | 125 |
* Run class path application that uses jdk.internal.misc.Unsafe |
36511 | 126 |
*/ |
127 |
public void testUnnamedModule() throws Exception { |
|
128 |
||
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
129 |
// java --add-exports java.base/jdk.internal.misc=ALL-UNNAMED \ |
36511 | 130 |
// -cp mods/$TESTMODULE jdk.test.UsesUnsafe |
131 |
||
132 |
String classpath = MODS_DIR.resolve(TEST1_MODULE).toString(); |
|
133 |
int exitValue |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
134 |
= executeTestJava("--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED", |
36511 | 135 |
"-cp", classpath, |
136 |
TEST1_MAIN_CLASS) |
|
137 |
.outputTo(System.out) |
|
138 |
.errorTo(System.out) |
|
139 |
.getExitValue(); |
|
140 |
||
141 |
assertTrue(exitValue == 0); |
|
142 |
} |
|
143 |
||
144 |
||
145 |
/** |
|
36966 | 146 |
* Run named module that uses jdk.internal.misc.Unsafe |
36511 | 147 |
*/ |
148 |
public void testNamedModule() throws Exception { |
|
149 |
||
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
150 |
// java --add-exports java.base/jdk.internal.misc=test \ |
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
151 |
// --module-path mods -m $TESTMODULE/$MAIN_CLASS |
36511 | 152 |
|
153 |
String mid = TEST1_MODULE + "/" + TEST1_MAIN_CLASS; |
|
154 |
int exitValue = |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
155 |
executeTestJava("--add-exports", "java.base/jdk.internal.misc=" + TEST1_MODULE, |
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
156 |
"--module-path", MODS_DIR.toString(), |
36511 | 157 |
"-m", mid) |
158 |
.outputTo(System.out) |
|
159 |
.errorTo(System.out) |
|
160 |
.getExitValue(); |
|
161 |
||
162 |
assertTrue(exitValue == 0); |
|
163 |
} |
|
164 |
||
52111
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
165 |
/** |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
166 |
* Test --add-exports with upgraded module |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
167 |
*/ |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
168 |
public void testWithUpgradedModule() throws Exception { |
36511 | 169 |
|
52111
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
170 |
// java --add-exports java.compiler/javax.tools.internal=m2 |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
171 |
// --upgrade-module-path upgrademods --module-path mods -m ... |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
172 |
String mid = TEST2_MODULE + "/" + TEST2_MAIN_CLASS; |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
173 |
int exitValue = executeTestJava( |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
174 |
"--add-exports", "java.compiler/javax.tools.internal=m2", |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
175 |
"--upgrade-module-path", UPGRADE_MODS_DIRS.toString(), |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
176 |
"--module-path", MODS_DIR.toString(), |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
177 |
"-m", mid) |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
178 |
.outputTo(System.out) |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
179 |
.errorTo(System.out) |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
180 |
.getExitValue(); |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
181 |
|
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
182 |
assertTrue(exitValue == 0); |
367b2cd49ec5
8212045: Add back tests removed from HashesTest.java and AddExportsTest.java
lancea
parents:
51675
diff
changeset
|
183 |
} |
36511 | 184 |
|
185 |
/** |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
186 |
* Test --add-exports with module that is added to the set of root modules |
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
187 |
* with --add-modules. |
36511 | 188 |
*/ |
189 |
public void testWithAddMods() throws Exception { |
|
190 |
||
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
191 |
// java --add-exports m4/jdk.test4=m3 --module-path mods -m ... |
36511 | 192 |
String mid = TEST3_MODULE + "/" + TEST3_MAIN_CLASS; |
193 |
int exitValue = executeTestJava( |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
194 |
"--add-exports", "m4/jdk.test4=m3", |
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
195 |
"--module-path", MODS_DIR.toString(), |
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
196 |
"--add-modules", TEST4_MODULE, |
36511 | 197 |
"-m", mid) |
198 |
.outputTo(System.out) |
|
199 |
.errorTo(System.out) |
|
200 |
.getExitValue(); |
|
201 |
||
202 |
assertTrue(exitValue == 0); |
|
203 |
} |
|
204 |
||
205 |
||
206 |
/** |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
207 |
* --add-exports and --add-opens allows duplicates |
36511 | 208 |
*/ |
209 |
public void testWithDuplicateOption() throws Exception { |
|
210 |
||
211 |
int exitValue |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
212 |
= executeTestJava("--add-exports", "java.base/jdk.internal.reflect=ALL-UNNAMED", |
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
37363
diff
changeset
|
213 |
"--add-exports", "java.base/jdk.internal.reflect=ALL-UNNAMED", |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
214 |
"--add-opens", "java.base/java.util=ALL-UNNAMED", |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
215 |
"--add-opens", "java.base/java.util=ALL-UNNAMED", |
36511 | 216 |
"-version") |
217 |
.outputTo(System.out) |
|
218 |
.errorTo(System.out) |
|
219 |
.getExitValue(); |
|
220 |
||
41414
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
221 |
assertTrue(exitValue == 0); |
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
222 |
} |
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
223 |
|
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
224 |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
225 |
private OutputAnalyzer execJava(String... options) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
226 |
try { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
227 |
return executeTestJava(options); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
228 |
} catch (Exception e) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
229 |
throw new Error(e); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
230 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
231 |
} |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
232 |
|
41414
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
233 |
/** |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
234 |
* Exercise --add-exports and --add-opens with unknown values. |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
235 |
* Warning is emitted. |
41414
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
236 |
*/ |
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
237 |
@Test(dataProvider = "unknownvalues") |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
238 |
public void testWithUnknownValue(String value, String ignore) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
239 |
Stream.of("--add-exports", "--add-opens") |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
240 |
.forEach(option -> { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
241 |
// --add-exports $VALUE -version |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
242 |
int exitValue = execJava(option, value, "-version") |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
243 |
.stderrShouldMatch("WARNING: .*.monkey.*") |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
244 |
.outputTo(System.out) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
245 |
.errorTo(System.out) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
246 |
.getExitValue(); |
41414
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
247 |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
248 |
assertTrue(exitValue == 0); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
249 |
}); |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
250 |
} |
41414
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
251 |
|
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
252 |
|
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
253 |
@DataProvider(name = "unknownvalues") |
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
254 |
public Object[][] unknownValues() { |
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
255 |
return new Object[][]{ |
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
256 |
|
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
257 |
{ "java.base/jdk.internal.misc=sun.monkey", null }, // unknown target |
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
258 |
{ "java.monkey/sun.monkey=ALL-UNNAMED", null }, // unknown module |
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
259 |
{ "java.base/sun.monkey=ALL-UNNAMED", null }, // unknown package |
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
260 |
{ "java.monkey/sun.monkey=ALL-UNNAMED", null }, // unknown module/package |
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
261 |
|
7fd4548e9733
8162401: Support multiple --add-exports and --add-reads with the same module/package
mchung
parents:
40261
diff
changeset
|
262 |
}; |
36511 | 263 |
} |
264 |
||
265 |
||
266 |
/** |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
267 |
* Exercise --add-exports and --add-opens with bad values |
36511 | 268 |
*/ |
269 |
@Test(dataProvider = "badvalues") |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
270 |
public void testWithBadValue(String value, String ignore) { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
271 |
Stream.of("--add-exports", "--add-opens") |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
272 |
.forEach(option -> { |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
273 |
// --add-exports $VALUE -version |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
274 |
int exitValue = execJava(option, value, "-version") |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
275 |
.outputTo(System.out) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
276 |
.errorTo(System.out) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
277 |
.getExitValue(); |
36511 | 278 |
|
279 |
assertTrue(exitValue != 0); |
|
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41414
diff
changeset
|
280 |
}); |
36511 | 281 |
} |
282 |
||
283 |
@DataProvider(name = "badvalues") |
|
284 |
public Object[][] badValues() { |
|
285 |
return new Object[][]{ |
|
286 |
||
36966 | 287 |
{ "java.base/jdk.internal.misc", null }, // missing target |
288 |
{ "java.base=ALL-UNNAMED", null }, // missing package |
|
289 |
{ "java.base/=ALL-UNNAMED", null } // missing package |
|
36511 | 290 |
|
291 |
}; |
|
292 |
} |
|
293 |
} |