# HG changeset patch # User mcimadamore # Date 1248946234 -3600 # Node ID 3fdb9f291a7e130d033616f69439a3fdca24ca31 # Parent 46fcb9a809a67f78181c4b5ac7507dc164b2aa03 6861837: JCK compilation failures Summary: Type-annotations processing is accessing type info before they are available in MemberEnter Reviewed-by: jjg Contributed-by: mali@csail.mit.edu diff -r 46fcb9a809a6 -r 3fdb9f291a7e langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Thu Jul 30 10:30:24 2009 +0100 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Thu Jul 30 10:30:34 2009 +0100 @@ -1040,15 +1040,6 @@ JavaFileObject prev = log.useSource(env.toplevel.sourcefile); try { enterTypeAnnotations(annotations); - - // enrich type parameter symbols... easier for annotation processors - if (tree instanceof JCTypeParameter) { - JCTypeParameter typeparam = (JCTypeParameter)tree; - ListBuffer buf = ListBuffer.lb(); - for (JCTypeAnnotation anno : annotations) - buf.add(anno.attribute_field); - typeparam.type.tsym.attributes_field = buf.toList(); - } } finally { log.useSource(prev); } diff -r 46fcb9a809a6 -r 3fdb9f291a7e langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Jul 30 10:30:24 2009 +0100 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Jul 30 10:30:34 2009 +0100 @@ -817,6 +817,23 @@ pop(); } + private boolean inClass = false; + + @Override + public void visitClassDef(JCClassDecl tree) { + if (!inClass) { + // Do not recurse into nested and inner classes since + // TransTypes.visitClassDef makes an invocation for each class + // separately. + inClass = true; + try { + super.visitClassDef(tree); + } finally { + inClass = false; + } + } + } + private TypeAnnotationPosition resolveFrame(JCTree tree, JCTree frame, List path, TypeAnnotationPosition p) { switch (frame.getKind()) { diff -r 46fcb9a809a6 -r 3fdb9f291a7e langtools/test/tools/javac/typeAnnotations/InnerClass.java --- a/langtools/test/tools/javac/typeAnnotations/InnerClass.java Thu Jul 30 10:30:24 2009 +0100 +++ b/langtools/test/tools/javac/typeAnnotations/InnerClass.java Thu Jul 30 10:30:34 2009 +0100 @@ -30,9 +30,30 @@ */ class InnerClass { + + InnerClass() {} + InnerClass(Object o) {} + private void a() { new Object() { public void method() { } }; } + + Object f1 = new InnerClass() { + void method() { } + }; + + Object f2 = new InnerClass() { + <@A R> void method() { } + }; + + Object f3 = new InnerClass(null) { + void method() { } + }; + + Object f4 = new InnerClass(null) { + <@A R> void method() { } + }; + @interface A { } }