author | jjg |
Sun, 12 May 2013 18:18:54 -0700 | |
changeset 17556 | eced45696767 |
parent 5520 | 86e4b9a9da40 |
child 27321 | c8eceba990bf |
permissions | -rw-r--r-- |
1109
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
1 |
/* |
17556
eced45696767
8014363: javac test class ToolTester handles classpath incorrectly
jjg
parents:
5520
diff
changeset
|
2 |
* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. |
1109
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
4 |
* |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
8 |
* |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
13 |
* accompanied this code). |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
14 |
* |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
18 |
* |
5520 | 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. |
|
1109
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
22 |
*/ |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
23 |
|
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
24 |
/* |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
25 |
* @test |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
26 |
* @bug 6733837 |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
27 |
* @summary Compiler API ignores locale settings |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
28 |
* @author Maurizio Cimadamore |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
29 |
* @library ../lib |
17556
eced45696767
8014363: javac test class ToolTester handles classpath incorrectly
jjg
parents:
5520
diff
changeset
|
30 |
* @build ToolTester |
eced45696767
8014363: javac test class ToolTester handles classpath incorrectly
jjg
parents:
5520
diff
changeset
|
31 |
* @run main T6733837 |
1109
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
32 |
*/ |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
33 |
|
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
34 |
import java.io.StringWriter; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
35 |
import java.io.PrintWriter; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
36 |
import java.net.URI; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
37 |
import java.util.Arrays; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
38 |
import java.util.List; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
39 |
import javax.tools.JavaFileObject; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
40 |
import javax.tools.SimpleJavaFileObject; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
41 |
import static javax.tools.JavaFileObject.Kind; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
42 |
import com.sun.source.util.JavacTask; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
43 |
|
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
44 |
public class T6733837 extends ToolTester { |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
45 |
|
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
46 |
public static void main(String... args) { |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
47 |
new T6733837().exec(); |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
48 |
} |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
49 |
|
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
50 |
public void exec() { |
3995
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
1109
diff
changeset
|
51 |
JavaFileObject sfo = new SimpleJavaFileObject(URI.create("myfo:/Test.java"),Kind.SOURCE) { |
1109
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
52 |
public CharSequence getCharContent(boolean ignoreEncodingErrors) { |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
53 |
return "\tclass ErroneousWithTab"; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
54 |
} |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
55 |
}; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
56 |
StringWriter sw = new StringWriter(); |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
57 |
PrintWriter out = new PrintWriter(sw); |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
58 |
List<? extends JavaFileObject> files = Arrays.asList(sfo); |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
59 |
task = tool.getTask(sw, fm, null, null, null, files); |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
60 |
try { |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
61 |
((JavacTask)task).analyze(); |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
62 |
} |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
63 |
catch (Throwable t) { |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
64 |
throw new Error("Compiler threw an exception"); |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
65 |
} |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
66 |
System.err.println(sw.toString()); |
3995
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
1109
diff
changeset
|
67 |
if (!sw.toString().contains("/Test.java")) |
1109
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
68 |
throw new Error("Bad source name in diagnostic"); |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
69 |
} |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
70 |
} |