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