test/tools/javac/api/6733837/T6733837.java

Sun, 12 May 2013 18:18:54 -0700

author
jjg
date
Sun, 12 May 2013 18:18:54 -0700
changeset 1733
e39669aea0bd
parent 554
9d9f26857129
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8014363: javac test class ToolTester handles classpath incorrectly
Reviewed-by: ksrini

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

mercurial