sundar@678: /* jjg@1669: * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. sundar@678: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. sundar@678: * sundar@678: * This code is free software; you can redistribute it and/or modify it sundar@678: * under the terms of the GNU General Public License version 2 only, as sundar@678: * published by the Free Software Foundation. sundar@678: * sundar@678: * This code is distributed in the hope that it will be useful, but WITHOUT sundar@678: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or sundar@678: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License sundar@678: * version 2 for more details (a copy is included in the LICENSE file that sundar@678: * accompanied this code). sundar@678: * sundar@678: * You should have received a copy of the GNU General Public License version sundar@678: * 2 along with this work; if not, write to the Free Software Foundation, sundar@678: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. sundar@678: * sundar@678: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA sundar@678: * or visit www.oracle.com if you need additional information or have any sundar@678: * questions. sundar@678: */ sundar@678: sundar@678: /* sundar@678: * @test sundar@678: * @bug 6900149 sundar@678: * @summary IllegalStateException when compiling same files and DiagnosticListener is set sundar@678: */ sundar@678: sundar@678: import java.io.*; sundar@678: import java.util.*; sundar@678: import javax.tools.*; sundar@678: import javax.tools.JavaCompiler.CompilationTask; sundar@678: sundar@678: public class T6900149 { sundar@678: public static void main(String[] args) throws IOException { sundar@678: DiagnosticCollector diag = sundar@678: new DiagnosticCollector(); sundar@678: JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); sundar@678: StandardJavaFileManager fm = sundar@678: compiler.getStandardFileManager(null, null, null); jjg@1669: File emptyFile = createTempFile("Empty.java"); sundar@678: File[] files = new File[] { emptyFile, emptyFile }; sundar@678: CompilationTask task = compiler.getTask(null, fm, diag, sundar@678: null, null, fm.getJavaFileObjects(files)); sundar@678: if (! task.call()) { sundar@678: throw new AssertionError("compilation failed"); sundar@678: } sundar@678: } jjg@1669: jjg@1669: private static File createTempFile(String path) throws IOException { jjg@1669: File f = new File(path); jjg@1669: try (FileWriter out = new FileWriter(f)) { } jjg@1669: return f; jjg@1669: } sundar@678: }