langtools/test/tools/javac/varargs/7043922/T7043922.java
author mcimadamore
Mon, 16 May 2011 09:38:04 +0100
changeset 9724 1eab738591a7
child 27319 030080f03e4f
permissions -rw-r--r--
7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor Summary: Attributing a constructor call does not clean up the compiler's attribution context Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9724
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
     1
/*
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
     4
 *
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
     8
 *
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    13
 * accompanied this code).
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    14
 *
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    18
 *
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    21
 * questions.
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    22
 */
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    23
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    24
/*
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    25
 * @test
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    26
 * @bug 7043922
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    27
 * @summary Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    28
 */
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    29
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    30
import com.sun.source.util.JavacTask;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    31
import com.sun.tools.javac.api.JavacTool;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    32
import com.sun.tools.javac.util.List;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    33
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    34
import java.net.URI;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    35
import java.util.Arrays;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    36
import java.util.Locale;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    37
import javax.tools.Diagnostic;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    38
import javax.tools.JavaCompiler;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    39
import javax.tools.JavaFileObject;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    40
import javax.tools.SimpleJavaFileObject;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    41
import javax.tools.StandardJavaFileManager;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    42
import javax.tools.ToolProvider;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    43
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    44
public class T7043922 {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    45
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    46
    ClassKind[] classKinds;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    47
    ConstructorKind[] constructorKinds;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    48
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    49
    T7043922(ClassKind[] classKinds, ConstructorKind[] constructorKinds) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    50
        this.classKinds = classKinds;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    51
        this.constructorKinds = constructorKinds;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    52
    }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    53
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    54
    void compileAndCheck() throws Exception {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    55
        JavaSource source = new JavaSource();
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    56
        ErrorChecker ec = new ErrorChecker();
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    57
        JavacTask ct = (JavacTask)tool.getTask(null, fm, ec,
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    58
                null, null, Arrays.asList(source));
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    59
        ct.analyze();
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    60
        if (ec.errorFound) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    61
            throw new Error("invalid diagnostics for source:\n" +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    62
                    source.getCharContent(true) +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    63
                    "\nCompiler diagnostics:\n" + ec.printDiags());
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    64
        }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    65
    }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    66
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    67
    class JavaSource extends SimpleJavaFileObject {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    68
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    69
        static final String source_template = "#C0 A0 { #K0 }\n" +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    70
                                              "#C1 A1 { #K1 }\n" +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    71
                                              "#C2 A2 { #K2 }\n" +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    72
                                              "class D {\n" +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    73
                                              "   void test() {\n" +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    74
                                              "      new A0(#V0) {\n" +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    75
                                              "         void test() {\n" +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    76
                                              "            new A1(#V1) {\n" +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    77
                                              "               void test() {\n" +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    78
                                              "                   new A2(#V2) {};\n" +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    79
                                              "               }\n" +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    80
                                              "            };\n" +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    81
                                              "         }\n" +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    82
                                              "      };\n" +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    83
                                              "   }\n" +
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    84
                                              "}\n";
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    85
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    86
        String source;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    87
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    88
        public JavaSource() {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    89
            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    90
            source = source_template;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    91
            for (int i = 0; i < 3; i++) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    92
                source = source.replaceAll("#C" + i, classKinds[i].classKind).
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    93
                    replaceAll("#K" + i, classKinds[i].getConstructor("A" + i, constructorKinds[i])).
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    94
                    replaceAll("#V" + i, constructorKinds[i].constrArgs);
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    95
            }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    96
        }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    97
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    98
        @Override
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
    99
        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   100
            return source;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   101
        }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   102
    }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   103
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   104
    /** global decls ***/
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   105
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   106
    enum ConstructorKind {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   107
        DEFAULT("", ""),
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   108
        FIXED_ARITY("String s", "\"\""),
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   109
        VARIABLE_ARITY("String... ss", "\"\",\"\"");
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   110
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   111
        String constrParam;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   112
        String constrArgs;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   113
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   114
        private ConstructorKind(String constrParam, String constrArgs) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   115
            this.constrParam = constrParam;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   116
            this.constrArgs = constrArgs;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   117
        }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   118
    }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   119
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   120
    enum ClassKind {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   121
        ABSTRACT("abstract class"),
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   122
        CLASS("class"),
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   123
        INTERFACE("interface");
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   124
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   125
        String classKind;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   126
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   127
        private ClassKind(String classKind) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   128
            this.classKind = classKind;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   129
        }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   130
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   131
        boolean isConstructorOk(ConstructorKind ck) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   132
            return this != INTERFACE ||
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   133
                    ck == ConstructorKind.DEFAULT;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   134
        }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   135
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   136
        String getConstructor(String className, ConstructorKind ck) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   137
            return this == INTERFACE ?
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   138
                "" :
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   139
                (className + "(" + ck.constrParam + ") {}");
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   140
        }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   141
    }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   142
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   143
    // Create a single file manager and JavaCompiler tool
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   144
    // and reuse them for each compile to save time.
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   145
    static final StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   146
    static final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   147
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   148
    public static void main(String... args) throws Exception {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   149
        for (ClassKind classKind1 : ClassKind.values()) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   150
            for (ConstructorKind constrKind1 : ConstructorKind.values()) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   151
                if (!classKind1.isConstructorOk(constrKind1)) continue;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   152
                for (ClassKind classKind2 : ClassKind.values()) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   153
                    for (ConstructorKind constrKind2 : ConstructorKind.values()) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   154
                        if (!classKind2.isConstructorOk(constrKind2)) continue;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   155
                        for (ClassKind classKind3 : ClassKind.values()) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   156
                            for (ConstructorKind constrKind3 : ConstructorKind.values()) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   157
                                if (!classKind3.isConstructorOk(constrKind3)) continue;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   158
                                new T7043922(new ClassKind[] { classKind1, classKind2, classKind3 },
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   159
                                        new ConstructorKind[] { constrKind1, constrKind2, constrKind3 }).compileAndCheck();
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   160
                            }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   161
                        }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   162
                    }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   163
                }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   164
            }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   165
        }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   166
    }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   167
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   168
    static class ErrorChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   169
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   170
        boolean errorFound;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   171
        List<String> errDiags = List.nil();
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   172
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   173
        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   174
            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   175
                errDiags = errDiags.append(diagnostic.getMessage(Locale.getDefault()));
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   176
                errorFound = true;
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   177
            }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   178
        }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   179
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   180
        String printDiags() {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   181
            StringBuilder buf = new StringBuilder();
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   182
            for (String s : errDiags) {
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   183
                buf.append(s);
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   184
                buf.append("\n");
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   185
            }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   186
            return buf.toString();
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   187
        }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   188
    }
1eab738591a7 7043922: Regression: internal compiler error for nested anonymous inner class featuring varargs constructor
mcimadamore
parents:
diff changeset
   189
}