# HG changeset patch # User jlahoda # Date 1421743877 -3600 # Node ID cbf8df1949576e9b11c23ca8e68dd91602d29902 # Parent 16eda7aedf899ccb5358cec44f3529ed8fe337de 8052070: javac crashes when there are duplicated type parameters Summary: Avoid eager completion of ClassSymbol while type parameters are being processed. Reviewed-by: jlahoda, mcimadamore Contributed-by: srikanth.adayapalam@oracle.com diff -r 16eda7aedf89 -r cbf8df194957 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java Mon Jan 19 18:29:45 2015 +0000 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java Tue Jan 20 09:51:17 2015 +0100 @@ -385,7 +385,7 @@ typeEnvs.put(c, localEnv); // Fill out class fields. - c.completer = typeEnter; + c.completer = null; // do not allow the initial completer linger on. c.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, c, tree); c.sourcefile = env.toplevel.sourcefile; c.members_field = WriteableScope.create(c); @@ -409,6 +409,9 @@ // Enter type parameters. ct.typarams_field = classEnter(tree.typarams, localEnv); + // install further completer for this type. + c.completer = typeEnter; + // Add non-local class to uncompleted, to make sure it will be // completed later. if (!c.isLocal() && uncompleted != null) uncompleted.append(c); diff -r 16eda7aedf89 -r cbf8df194957 langtools/test/tools/javac/8052070/DuplicateTypeParameter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/8052070/DuplicateTypeParameter.java Tue Jan 20 09:51:17 2015 +0100 @@ -0,0 +1,15 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8052070 + * @summary javac crashes when there are duplicated type parameters + * @compile/fail/ref=DuplicateTypeParameter.out -XDrawDiagnostics DuplicateTypeParameter.java + */ + +public class DuplicateTypeParameter { + class Inner {} + public void foo() { + class Local {}; + } +} + +class Secondary {} diff -r 16eda7aedf89 -r cbf8df194957 langtools/test/tools/javac/8052070/DuplicateTypeParameter.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/8052070/DuplicateTypeParameter.out Tue Jan 20 09:51:17 2015 +0100 @@ -0,0 +1,5 @@ +DuplicateTypeParameter.java:8:40: compiler.err.already.defined: kindname.type.variable, T, kindname.class, DuplicateTypeParameter +DuplicateTypeParameter.java:9:21: compiler.err.already.defined: kindname.type.variable, P, kindname.class, DuplicateTypeParameter.Inner +DuplicateTypeParameter.java:15:20: compiler.err.already.defined: kindname.type.variable, D, kindname.class, Secondary +DuplicateTypeParameter.java:11:25: compiler.err.already.defined: kindname.type.variable, M, kindname.class, Local +4 errors