author | vromero |
Wed, 18 Apr 2018 16:02:53 -0400 | |
changeset 49822 | 53aae0c219e6 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
38611
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
1 |
/* |
43874
d49715456f51
8173308: JAVAC_OPTIONS should be updated to align with JAVA_OPTIONS
ksrini
parents:
40308
diff
changeset
|
2 |
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. |
38611
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
4 |
* |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
8 |
* |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
14 |
* |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
18 |
* |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
21 |
* questions. |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
22 |
*/ |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
23 |
|
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
24 |
/* |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
25 |
* @test |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
26 |
* @bug 8156962 |
43874
d49715456f51
8173308: JAVAC_OPTIONS should be updated to align with JAVA_OPTIONS
ksrini
parents:
40308
diff
changeset
|
27 |
* @summary Tests use of JDK_JAVAC_OPTIONS env variable |
38611
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
28 |
* @library /tools/lib |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
29 |
* @modules jdk.compiler/com.sun.tools.javac.api |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
30 |
* jdk.compiler/com.sun.tools.javac.main |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
31 |
* @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
32 |
* @run main EnvVarTest |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
33 |
*/ |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
34 |
|
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
35 |
import java.nio.file.Path; |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
36 |
|
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
37 |
import toolbox.JavacTask; |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
38 |
import toolbox.Task.Expect; |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
39 |
import toolbox.Task.Mode; |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
40 |
|
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
41 |
public class EnvVarTest extends ModuleTestBase { |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
42 |
|
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
43 |
public static void main(String... args) throws Exception { |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
44 |
new EnvVarTest().runTests(); |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
45 |
} |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
46 |
|
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
47 |
@Test |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
48 |
public void testAddExports(Path base) throws Exception { |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
49 |
Path src = base.resolve("src"); |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
50 |
// the package in the following call should be one that is not |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
51 |
// available by default, including via @modules |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
52 |
tb.writeJavaFiles(src, |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
53 |
"package p; public class C { com.sun.tools.javac.jvm.Target t; }"); |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
54 |
Path classes = base.resolve("classes"); |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
55 |
tb.createDirectories(classes); |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
56 |
|
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
57 |
tb.out.println("test that compilation fails if addExports is not provided"); |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
58 |
new JavacTask(tb) |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
59 |
.outdir(classes) |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
60 |
.files(findJavaFiles(src)) |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
61 |
.run(Expect.FAIL) |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
62 |
.writeAll(); |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
63 |
|
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
64 |
tb.out.println("test that addExports can be given to javac"); |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
65 |
new JavacTask(tb) |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
38611
diff
changeset
|
66 |
.options("--add-exports", "jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED") |
38611
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
67 |
.outdir(classes) |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
68 |
.files(findJavaFiles(src)) |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
69 |
.run(Expect.SUCCESS) |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
70 |
.writeAll(); |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
71 |
|
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
72 |
tb.out.println("test that addExports can be provided with env variable"); |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
73 |
new JavacTask(tb, Mode.EXEC) |
43874
d49715456f51
8173308: JAVAC_OPTIONS should be updated to align with JAVA_OPTIONS
ksrini
parents:
40308
diff
changeset
|
74 |
.envVar("JDK_JAVAC_OPTIONS", "--add-exports jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED") |
38611
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
75 |
.outdir(classes) |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
76 |
.files(findJavaFiles(src)) |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
77 |
.run(Expect.SUCCESS) |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
78 |
.writeAll(); |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
79 |
|
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
80 |
tb.out.println("test that addExports can be provided with env variable using @file"); |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
81 |
Path atFile = src.resolve("at-file.txt"); |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
82 |
tb.writeFile(atFile, |
40308
274367a99f98
8136930: Simplify use of module-system options by custom launchers
jjg
parents:
38611
diff
changeset
|
83 |
"--add-exports jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED"); |
38611
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
84 |
|
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
85 |
new JavacTask(tb, Mode.EXEC) |
43874
d49715456f51
8173308: JAVAC_OPTIONS should be updated to align with JAVA_OPTIONS
ksrini
parents:
40308
diff
changeset
|
86 |
.envVar("JDK_JAVAC_OPTIONS", "@" + atFile) |
38611
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
87 |
.outdir(classes) |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
88 |
.files(findJavaFiles(src)) |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
89 |
.run(Expect.SUCCESS) |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
90 |
.writeAll(); |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
91 |
} |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
92 |
|
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
93 |
} |
b5a479aff686
8156962: javac should support options specified in _JAVAC_OPTIONS
jjg
parents:
diff
changeset
|
94 |