author | vromero |
Mon, 16 Dec 2013 15:07:13 +0000 | |
changeset 22149 | c7e024d637bf |
parent 6577 | 96c6451389fc |
child 26100 | bb7dd001d190 |
permissions | -rw-r--r-- |
6577 | 1 |
/* |
22149
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
2 |
* Copyright (c) 2010, 2013, 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 |
|
22149
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
28 |
* @library /tools/javac/lib |
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
29 |
* @build ToolBox |
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
30 |
* @run main ToolProviderTest1 |
6577 | 31 |
*/ |
32 |
||
22149
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
33 |
import java.util.ArrayList; |
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
34 |
import java.util.List; |
6577 | 35 |
|
36 |
// verify that running accessing ToolProvider by itself does not |
|
37 |
// trigger loading com.sun.tools.javac.* |
|
38 |
public class ToolProviderTest1 { |
|
39 |
public static void main(String... args) throws Exception { |
|
40 |
if (args.length > 0) { |
|
41 |
System.err.println(Class.forName(args[0], true, null)); |
|
42 |
return; |
|
43 |
} |
|
44 |
||
45 |
new ToolProviderTest1().run(); |
|
46 |
} |
|
47 |
||
48 |
void run() throws Exception { |
|
49 |
String classpath = System.getProperty("java.class.path"); |
|
50 |
||
22149
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
51 |
List<String> output = new ArrayList<>(); |
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
52 |
ToolBox.AnyToolArgs javaParams = |
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
53 |
new ToolBox.AnyToolArgs() |
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
54 |
.appendArgs(ToolBox.javaBinary) |
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
55 |
.appendArgs(ToolBox.testVMOpts) |
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
56 |
.appendArgs(ToolBox.testJavaOpts) |
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
57 |
.appendArgs("-verbose:class", |
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
58 |
"-classpath", classpath, |
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
59 |
ToolProviderTest1.class.getName(), |
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
60 |
"javax.tools.ToolProvider") |
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
61 |
.setErrOutput(output) |
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
62 |
.setStdOutput(output); |
6577 | 63 |
|
22149
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
64 |
ToolBox.executeCommand(javaParams); |
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
65 |
|
c7e024d637bf
8028708: TEST_BUG, Tests should pass through VM options, langtools tests
vromero
parents:
6577
diff
changeset
|
66 |
for (String line : output) { |
6577 | 67 |
System.err.println(line); |
68 |
if (line.contains("com.sun.tools.javac.")) |
|
69 |
error(">>> " + line); |
|
70 |
} |
|
71 |
||
72 |
if (errors > 0) |
|
73 |
throw new Exception(errors + " errors occurred"); |
|
74 |
} |
|
75 |
||
76 |
void error(String msg) { |
|
77 |
System.err.println(msg); |
|
78 |
errors++; |
|
79 |
} |
|
80 |
||
81 |
int errors; |
|
82 |
} |