author | peterz |
Fri, 28 May 2010 13:32:40 +0400 | |
changeset 5594 | 3db39773da2e |
parent 3995 | 73af8b6fb8bc |
child 5520 | 86e4b9a9da40 |
permissions | -rw-r--r-- |
1109
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
1 |
/* |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
2 |
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. |
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 |
* |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
21 |
* have any questions. |
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 |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
30 |
*/ |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
31 |
|
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
32 |
import java.io.StringWriter; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
33 |
import java.io.PrintWriter; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
34 |
import java.net.URI; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
35 |
import java.util.Arrays; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
36 |
import java.util.List; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
37 |
import javax.tools.JavaFileObject; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
38 |
import javax.tools.SimpleJavaFileObject; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
39 |
import static javax.tools.JavaFileObject.Kind; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
40 |
import com.sun.source.util.JavacTask; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
41 |
|
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
42 |
public class T6733837 extends ToolTester { |
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 static void main(String... args) { |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
45 |
new T6733837().exec(); |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
46 |
} |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
47 |
|
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
48 |
public void exec() { |
3995
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
1109
diff
changeset
|
49 |
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
|
50 |
public CharSequence getCharContent(boolean ignoreEncodingErrors) { |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
51 |
return "\tclass ErroneousWithTab"; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
52 |
} |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
53 |
}; |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
54 |
StringWriter sw = new StringWriter(); |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
55 |
PrintWriter out = new PrintWriter(sw); |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
56 |
List<? extends JavaFileObject> files = Arrays.asList(sfo); |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
57 |
task = tool.getTask(sw, fm, null, null, null, files); |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
58 |
try { |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
59 |
((JavacTask)task).analyze(); |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
60 |
} |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
61 |
catch (Throwable t) { |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
62 |
throw new Error("Compiler threw an exception"); |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
63 |
} |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
64 |
System.err.println(sw.toString()); |
3995
73af8b6fb8bc
6410637: Make decision on deprecated methods in DefaultFileManager and BaseFileObject.
jjg
parents:
1109
diff
changeset
|
65 |
if (!sw.toString().contains("/Test.java")) |
1109
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
66 |
throw new Error("Bad source name in diagnostic"); |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
67 |
} |
853d8c191eac
6733837: Recent work on javac diagnostic affected javac output
mcimadamore
parents:
diff
changeset
|
68 |
} |