author | shade |
Thu, 03 Mar 2016 23:57:29 +0300 | |
changeset 36553 | 203b2b5d149b |
parent 35356 | e919fd8db52c |
child 40308 | 274367a99f98 |
permissions | -rw-r--r-- |
25290 | 1 |
/* |
35356
e919fd8db52c
8056989: Sjavac --server option should be optional
alundblad
parents:
32799
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
25290 | 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 |
|
32337 | 7 |
* published by the Free Software Foundation. |
25290 | 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 8047183 |
|
27 |
* @summary JDK build fails with sjavac enabled |
|
25603
d5fa4eab2d26
8046824: class SJavacTestUtil and *Wrapper are redundant and should be removed
jjg
parents:
25290
diff
changeset
|
28 |
* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26271
diff
changeset
|
29 |
* @modules jdk.compiler |
25603
d5fa4eab2d26
8046824: class SJavacTestUtil and *Wrapper are redundant and should be removed
jjg
parents:
25290
diff
changeset
|
30 |
* @build Wrapper |
d5fa4eab2d26
8046824: class SJavacTestUtil and *Wrapper are redundant and should be removed
jjg
parents:
25290
diff
changeset
|
31 |
* @run main Wrapper IgnoreSymbolFile |
25290 | 32 |
*/ |
33 |
||
34 |
import java.io.File; |
|
35 |
import java.io.FileWriter; |
|
36 |
import java.io.IOException; |
|
37 |
import java.io.PrintStream; |
|
38 |
import java.lang.reflect.Method; |
|
39 |
import java.util.Arrays; |
|
40 |
||
41 |
public class IgnoreSymbolFile { |
|
42 |
public static void main(String... args) throws Exception { |
|
25603
d5fa4eab2d26
8046824: class SJavacTestUtil and *Wrapper are redundant and should be removed
jjg
parents:
25290
diff
changeset
|
43 |
IgnoreSymbolFile test = new IgnoreSymbolFile(); |
d5fa4eab2d26
8046824: class SJavacTestUtil and *Wrapper are redundant and should be removed
jjg
parents:
25290
diff
changeset
|
44 |
test.run(); |
25290 | 45 |
} |
46 |
||
47 |
void run() throws Exception { |
|
48 |
String body = |
|
49 |
"package p;\n" |
|
50 |
+ "import sun.reflect.annotation.*;\n" |
|
51 |
+ "class X {\n" |
|
52 |
+ " ExceptionProxy proxy;" |
|
53 |
+ "}"; |
|
54 |
writeFile("src/p/X.java", body); |
|
55 |
||
56 |
new File("classes").mkdirs(); |
|
57 |
||
35356
e919fd8db52c
8056989: Sjavac --server option should be optional
alundblad
parents:
32799
diff
changeset
|
58 |
int rc1 = compile("-d", "classes", |
32799 | 59 |
"--state-dir=classes", |
60 |
"-Werror", |
|
61 |
"src"); |
|
25290 | 62 |
if (rc1 == 0) |
63 |
error("compilation succeeded unexpectedly"); |
|
64 |
||
35356
e919fd8db52c
8056989: Sjavac --server option should be optional
alundblad
parents:
32799
diff
changeset
|
65 |
int rc2 = compile("-d", "classes", |
32799 | 66 |
"--state-dir=classes", |
67 |
"-Werror", |
|
68 |
"-XDignore.symbol.file=true", |
|
69 |
"src"); |
|
25290 | 70 |
if (rc2 != 0) |
71 |
error("compilation failed unexpectedly: rc=" + rc2); |
|
72 |
||
73 |
if (errors > 0) |
|
74 |
throw new Exception(errors + " errors occurred"); |
|
75 |
} |
|
76 |
||
77 |
int compile(String... args) throws ReflectiveOperationException { |
|
78 |
// Use reflection to avoid a compile-time dependency on sjavac Main |
|
79 |
System.err.println("compile: " + Arrays.toString(args)); |
|
80 |
Class<?> c = Class.forName("com.sun.tools.sjavac.Main"); |
|
26271
97603426a4ce
8054500: Refactor sjavac Main class into ClientMain and ServerMain
alundblad
parents:
25603
diff
changeset
|
81 |
Method m = c.getDeclaredMethod("go", String[].class); |
97603426a4ce
8054500: Refactor sjavac Main class into ClientMain and ServerMain
alundblad
parents:
25603
diff
changeset
|
82 |
int rc = (Integer) m.invoke(null, (Object) args); |
25290 | 83 |
System.err.println("rc=" + rc); |
84 |
return rc; |
|
85 |
} |
|
86 |
||
87 |
void writeFile(String path, String body) throws IOException { |
|
88 |
File f = new File(path); |
|
89 |
if (f.getParentFile() != null) |
|
90 |
f.getParentFile().mkdirs(); |
|
91 |
try (FileWriter w = new FileWriter(f)) { |
|
92 |
w.write(body); |
|
93 |
} |
|
94 |
} |
|
95 |
||
96 |
void error(String msg) { |
|
97 |
System.err.println("Error: " + msg); |
|
98 |
errors++; |
|
99 |
} |
|
100 |
||
101 |
int errors; |
|
102 |
} |