author | sogoel |
Wed, 24 Dec 2014 11:17:51 -0800 | |
changeset 28276 | ec66954fa850 |
parent 26271 | 97603426a4ce |
child 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
25290 | 1 |
/* |
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
|
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. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
/* |
|
27 |
* @test |
|
28 |
* @bug 8047183 |
|
29 |
* @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
|
30 |
* |
d5fa4eab2d26
8046824: class SJavacTestUtil and *Wrapper are redundant and should be removed
jjg
parents:
25290
diff
changeset
|
31 |
* @build Wrapper |
d5fa4eab2d26
8046824: class SJavacTestUtil and *Wrapper are redundant and should be removed
jjg
parents:
25290
diff
changeset
|
32 |
* @run main Wrapper IgnoreSymbolFile |
25290 | 33 |
*/ |
34 |
||
35 |
import java.io.File; |
|
36 |
import java.io.FileWriter; |
|
37 |
import java.io.IOException; |
|
38 |
import java.io.PrintStream; |
|
39 |
import java.lang.reflect.Method; |
|
40 |
import java.util.Arrays; |
|
41 |
||
42 |
public class IgnoreSymbolFile { |
|
43 |
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
|
44 |
IgnoreSymbolFile test = new IgnoreSymbolFile(); |
d5fa4eab2d26
8046824: class SJavacTestUtil and *Wrapper are redundant and should be removed
jjg
parents:
25290
diff
changeset
|
45 |
test.run(); |
25290 | 46 |
} |
47 |
||
48 |
void run() throws Exception { |
|
49 |
String body = |
|
50 |
"package p;\n" |
|
51 |
+ "import sun.reflect.annotation.*;\n" |
|
52 |
+ "class X {\n" |
|
53 |
+ " ExceptionProxy proxy;" |
|
54 |
+ "}"; |
|
55 |
writeFile("src/p/X.java", body); |
|
56 |
||
57 |
new File("classes").mkdirs(); |
|
58 |
||
59 |
String server = "--server:portfile=testserver,background=false"; |
|
60 |
int rc1 = compile(server, "-d", "classes", "-Werror", "src"); |
|
61 |
if (rc1 == 0) |
|
62 |
error("compilation succeeded unexpectedly"); |
|
63 |
||
64 |
int rc2 = compile(server, "-d", "classes", "-Werror", "-XDignore.symbol.file=true", "src"); |
|
65 |
if (rc2 != 0) |
|
66 |
error("compilation failed unexpectedly: rc=" + rc2); |
|
67 |
||
68 |
if (errors > 0) |
|
69 |
throw new Exception(errors + " errors occurred"); |
|
70 |
} |
|
71 |
||
72 |
int compile(String... args) throws ReflectiveOperationException { |
|
73 |
// Use reflection to avoid a compile-time dependency on sjavac Main |
|
74 |
System.err.println("compile: " + Arrays.toString(args)); |
|
75 |
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
|
76 |
Method m = c.getDeclaredMethod("go", String[].class); |
97603426a4ce
8054500: Refactor sjavac Main class into ClientMain and ServerMain
alundblad
parents:
25603
diff
changeset
|
77 |
int rc = (Integer) m.invoke(null, (Object) args); |
25290 | 78 |
System.err.println("rc=" + rc); |
79 |
return rc; |
|
80 |
} |
|
81 |
||
82 |
void writeFile(String path, String body) throws IOException { |
|
83 |
File f = new File(path); |
|
84 |
if (f.getParentFile() != null) |
|
85 |
f.getParentFile().mkdirs(); |
|
86 |
try (FileWriter w = new FileWriter(f)) { |
|
87 |
w.write(body); |
|
88 |
} |
|
89 |
} |
|
90 |
||
91 |
void error(String msg) { |
|
92 |
System.err.println("Error: " + msg); |
|
93 |
errors++; |
|
94 |
} |
|
95 |
||
96 |
int errors; |
|
97 |
} |