0N/A/*
553N/A * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * @test
0N/A * @bug 6306137
0N/A * @summary JSR 199: encoding option doesn't affect standard file manager
0N/A * @author Peter von der Ahé
0N/A * @ignore
0N/A * Need to make the contentCache in JavacFileManager be aware of changes to the encoding.
0N/A * Need to propogate -source (and -encoding?) down to the JavacFileManager
0N/A */
0N/A
0N/Aimport java.io.File;
0N/Aimport java.util.Arrays;
0N/Aimport javax.tools.*;
0N/A
0N/Apublic class T6306137 {
0N/A boolean error;
0N/A final StandardJavaFileManager fm;
0N/A final JavaCompiler compiler;
0N/A Iterable<? extends JavaFileObject> files;
0N/A DiagnosticListener<JavaFileObject> dl;
0N/A
0N/A T6306137() {
0N/A dl = new DiagnosticListener<JavaFileObject>() {
0N/A public void report(Diagnostic<? extends JavaFileObject> message) {
0N/A if (message.getKind() == Diagnostic.Kind.ERROR)
0N/A error = true;
0N/A System.out.println(message.getSource()
0N/A +":"+message.getStartPosition()+":"
0N/A +message.getStartPosition()+":"+message.getPosition());
0N/A System.out.println(message.toString());
0N/A System.out.format("Found problem: %s%n", message.getCode());
0N/A System.out.flush();
0N/A }
0N/A };
0N/A compiler = ToolProvider.getSystemJavaCompiler();
0N/A fm = compiler.getStandardFileManager(dl, null, null);
0N/A String srcdir = System.getProperty("test.src");
0N/A files =
0N/A fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcdir, "T6306137.java")));
0N/A }
0N/A
0N/A void test(String encoding, boolean good) {
0N/A error = false;
0N/A Iterable<String> args = Arrays.asList("-source", "6", "-encoding", encoding, "-d", ".");
0N/A compiler.getTask(null, fm, dl, args, null, files).call();
0N/A if (error == good) {
0N/A if (error) {
0N/A throw new AssertionError("Error reported");
0N/A } else {
0N/A throw new AssertionError("No error reported");
0N/A }
0N/A }
0N/A }
0N/A
0N/A public static void main(String[] args) {
0N/A T6306137 self = new T6306137();
0N/A self.test("utf-8", true);
0N/A self.test("ascii", false);
0N/A self.test("utf-8", true);
0N/A }
0N/A}