T6733837.java revision 99
653N/A/*
653N/A * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
653N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
653N/A *
943N/A * This code is free software; you can redistribute it and/or modify it
653N/A * under the terms of the GNU General Public License version 2 only, as
653N/A * published by the Free Software Foundation.
919N/A *
919N/A * This code is distributed in the hope that it will be useful, but WITHOUT
919N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
919N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
919N/A * version 2 for more details (a copy is included in the LICENSE file that
919N/A * accompanied this code).
919N/A *
919N/A * You should have received a copy of the GNU General Public License version
919N/A * 2 along with this work; if not, write to the Free Software Foundation,
919N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
919N/A *
919N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
919N/A * CA 95054 USA or visit www.sun.com if you need additional information or
919N/A * have any questions.
919N/A */
919N/A
919N/A/*
653N/A * @test
653N/A * @bug 6733837
653N/A * @summary Compiler API ignores locale settings
653N/A * @author Maurizio Cimadamore
653N/A * @library ../lib
653N/A */
970N/A
970N/Aimport java.io.StringWriter;
970N/Aimport java.io.PrintWriter;
970N/Aimport java.net.URI;
970N/Aimport java.util.Arrays;
970N/Aimport java.util.List;
970N/Aimport javax.tools.JavaFileObject;
970N/Aimport javax.tools.SimpleJavaFileObject;
653N/Aimport static javax.tools.JavaFileObject.Kind;
911N/Aimport com.sun.source.util.JavacTask;
911N/A
911N/Apublic class T6733837 extends ToolTester {
911N/A
911N/A public static void main(String... args) {
653N/A new T6733837().exec();
653N/A }
653N/A
653N/A public void exec() {
653N/A JavaFileObject sfo = new SimpleJavaFileObject(URI.create(""),Kind.SOURCE) {
653N/A public CharSequence getCharContent(boolean ignoreEncodingErrors) {
653N/A return "\tclass ErroneousWithTab";
653N/A }
653N/A @Override
653N/A public String getName() {
911N/A return "RELATIVEPATH";
911N/A }
911N/A };
911N/A StringWriter sw = new StringWriter();
911N/A PrintWriter out = new PrintWriter(sw);
911N/A List<? extends JavaFileObject> files = Arrays.asList(sfo);
653N/A task = tool.getTask(sw, fm, null, null, null, files);
653N/A try {
653N/A ((JavacTask)task).analyze();
653N/A }
653N/A catch (Throwable t) {
653N/A throw new Error("Compiler threw an exception");
653N/A }
653N/A System.err.println(sw.toString());
653N/A if (sw.toString().contains("RELATIVEPATH"))
837N/A throw new Error("Bad source name in diagnostic");
837N/A }
653N/A}
653N/A