6861837: JCK compilation failures
authormcimadamore
Thu, 30 Jul 2009 10:30:34 +0100
changeset 3542 3fdb9f291a7e
parent 3541 46fcb9a809a6
child 3543 58b72b096bcb
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
langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java
langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java
langtools/test/tools/javac/typeAnnotations/InnerClass.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<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/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<JCTree> path, TypeAnnotationPosition p) {
             switch (frame.getKind()) {
--- 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 <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 { }
 }