author | jjg |
Thu, 31 Mar 2016 15:20:50 -0700 | |
changeset 36778 | e04318f39f92 |
parent 36526 | 3b41f1c69604 |
child 37853 | b4ea8806ad1a |
permissions | -rw-r--r-- |
6577 | 1 |
/* |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
2 |
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. |
6577 | 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 |
|
26 |
* @bug 6604599 |
|
27 |
* @summary ToolProvider should be less compiler-specific |
|
26100 | 28 |
* @library /tools/lib |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26100
diff
changeset
|
29 |
* @modules jdk.compiler/com.sun.tools.javac.api |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26100
diff
changeset
|
30 |
* jdk.compiler/com.sun.tools.javac.main |
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
31 |
* @build toolbox.ToolBox toolbox.JavaTask |
22149
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
32 |
* @run main ToolProviderTest1 |
6577 | 33 |
*/ |
34 |
||
22149
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
35 |
import java.util.List; |
6577 | 36 |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
37 |
import toolbox.JavaTask; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
38 |
import toolbox.Task; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
39 |
import toolbox.ToolBox; |
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
40 |
|
6577 | 41 |
// verify that running accessing ToolProvider by itself does not |
42 |
// trigger loading com.sun.tools.javac.* |
|
43 |
public class ToolProviderTest1 { |
|
44 |
public static void main(String... args) throws Exception { |
|
45 |
if (args.length > 0) { |
|
46 |
System.err.println(Class.forName(args[0], true, null)); |
|
47 |
return; |
|
48 |
} |
|
49 |
||
50 |
new ToolProviderTest1().run(); |
|
51 |
} |
|
52 |
||
53 |
void run() throws Exception { |
|
26100 | 54 |
ToolBox tb = new ToolBox(); |
6577 | 55 |
String classpath = System.getProperty("java.class.path"); |
56 |
||
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
57 |
List<String> lines = new JavaTask(tb) |
26100 | 58 |
.vmOptions("-verbose:class") |
59 |
.classpath(classpath) |
|
60 |
.className(getClass().getName()) |
|
61 |
.classArgs("javax.tools.ToolProvider") |
|
62 |
.run() |
|
36778
e04318f39f92
8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents:
36526
diff
changeset
|
63 |
.getOutputLines(Task.OutputKind.STDOUT); |
6577 | 64 |
|
26100 | 65 |
for (String line : lines) { |
6577 | 66 |
System.err.println(line); |
67 |
if (line.contains("com.sun.tools.javac.")) |
|
68 |
error(">>> " + line); |
|
69 |
} |
|
70 |
||
71 |
if (errors > 0) |
|
72 |
throw new Exception(errors + " errors occurred"); |
|
73 |
} |
|
74 |
||
75 |
void error(String msg) { |
|
76 |
System.err.println(msg); |
|
77 |
errors++; |
|
78 |
} |
|
79 |
||
80 |
int errors; |
|
81 |
} |