Mon, 13 Dec 2010 15:11:00 -0800
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
Reviewed-by: jjg, darcy
sundar@678 | 1 | /* |
sundar@678 | 2 | * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
sundar@678 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
sundar@678 | 4 | * |
sundar@678 | 5 | * This code is free software; you can redistribute it and/or modify it |
sundar@678 | 6 | * under the terms of the GNU General Public License version 2 only, as |
sundar@678 | 7 | * published by the Free Software Foundation. |
sundar@678 | 8 | * |
sundar@678 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
sundar@678 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
sundar@678 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
sundar@678 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
sundar@678 | 13 | * accompanied this code). |
sundar@678 | 14 | * |
sundar@678 | 15 | * You should have received a copy of the GNU General Public License version |
sundar@678 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
sundar@678 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
sundar@678 | 18 | * |
sundar@678 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
sundar@678 | 20 | * or visit www.oracle.com if you need additional information or have any |
sundar@678 | 21 | * questions. |
sundar@678 | 22 | */ |
sundar@678 | 23 | |
sundar@678 | 24 | /* |
sundar@678 | 25 | * @test |
sundar@678 | 26 | * @bug 6900149 |
sundar@678 | 27 | * @summary IllegalStateException when compiling same files and DiagnosticListener is set |
sundar@678 | 28 | */ |
sundar@678 | 29 | |
sundar@678 | 30 | import java.io.*; |
sundar@678 | 31 | import java.util.*; |
sundar@678 | 32 | import javax.tools.*; |
sundar@678 | 33 | import javax.tools.JavaCompiler.CompilationTask; |
sundar@678 | 34 | |
sundar@678 | 35 | public class T6900149 { |
sundar@678 | 36 | public static void main(String[] args) throws IOException { |
sundar@678 | 37 | DiagnosticCollector<JavaFileObject> diag = |
sundar@678 | 38 | new DiagnosticCollector<JavaFileObject>(); |
sundar@678 | 39 | JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); |
sundar@678 | 40 | StandardJavaFileManager fm = |
sundar@678 | 41 | compiler.getStandardFileManager(null, null, null); |
sundar@678 | 42 | File emptyFile = File.createTempFile("Empty", ".java"); |
sundar@678 | 43 | File[] files = new File[] { emptyFile, emptyFile }; |
sundar@678 | 44 | CompilationTask task = compiler.getTask(null, fm, diag, |
sundar@678 | 45 | null, null, fm.getJavaFileObjects(files)); |
sundar@678 | 46 | if (! task.call()) { |
sundar@678 | 47 | throw new AssertionError("compilation failed"); |
sundar@678 | 48 | } |
sundar@678 | 49 | } |
sundar@678 | 50 | } |