changeset 363:6d0add6ad778

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
author mcimadamore
date Thu, 30 Jul 2009 10:30:34 +0100
parents dd5c51734ad9
children 23505e6ea22d
files src/share/classes/com/sun/tools/javac/comp/MemberEnter.java src/share/classes/com/sun/tools/javac/comp/TransTypes.java test/tools/javac/typeAnnotations/InnerClass.java
diffstat 3 files changed, 38 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Thu Jul 30 10:30:24 2009 +0100
+++ b/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<Attribute.Compound> buf = ListBuffer.lb();
-                            for (JCTypeAnnotation anno : annotations)
-                                buf.add(anno.attribute_field);
-                            typeparam.type.tsym.attributes_field = buf.toList();
-                        }
                     } finally {
                         log.useSource(prev);
                     }
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Thu Jul 30 10:30:24 2009 +0100
+++ b/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<JCTree> path, TypeAnnotationPosition p) {
             switch (frame.getKind()) {
--- a/test/tools/javac/typeAnnotations/InnerClass.java	Thu Jul 30 10:30:24 2009 +0100
+++ b/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 <R> void method() { }
         };
     }
+
+    Object f1 = new InnerClass() {
+            <R> void method() { }
+        };
+
+    Object f2 = new InnerClass() {
+            <@A R> void method() { }
+        };
+
+    Object f3 = new InnerClass(null) {
+            <R> void method() { }
+        };
+
+    Object f4 = new InnerClass(null) {
+            <@A R> void method() { }
+        };
+    @interface A { }
 }