6861837: JCK compilation failures

Thu, 30 Jul 2009 10:30:34 +0100

author
mcimadamore
date
Thu, 30 Jul 2009 10:30:34 +0100
changeset 344
6d0add6ad778
parent 343
dd5c51734ad9
child 345
23505e6ea22d

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

src/share/classes/com/sun/tools/javac/comp/MemberEnter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/comp/TransTypes.java file | annotate | diff | comparison | revisions
test/tools/javac/typeAnnotations/InnerClass.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Thu Jul 30 10:30:24 2009 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Thu Jul 30 10:30:34 2009 +0100
     1.3 @@ -1040,15 +1040,6 @@
     1.4                      JavaFileObject prev = log.useSource(env.toplevel.sourcefile);
     1.5                      try {
     1.6                          enterTypeAnnotations(annotations);
     1.7 -
     1.8 -                        // enrich type parameter symbols... easier for annotation processors
     1.9 -                        if (tree instanceof JCTypeParameter) {
    1.10 -                            JCTypeParameter typeparam = (JCTypeParameter)tree;
    1.11 -                            ListBuffer<Attribute.Compound> buf = ListBuffer.lb();
    1.12 -                            for (JCTypeAnnotation anno : annotations)
    1.13 -                                buf.add(anno.attribute_field);
    1.14 -                            typeparam.type.tsym.attributes_field = buf.toList();
    1.15 -                        }
    1.16                      } finally {
    1.17                          log.useSource(prev);
    1.18                      }
     2.1 --- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Thu Jul 30 10:30:24 2009 +0100
     2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Thu Jul 30 10:30:34 2009 +0100
     2.3 @@ -817,6 +817,23 @@
     2.4              pop();
     2.5          }
     2.6  
     2.7 +        private boolean inClass = false;
     2.8 +
     2.9 +        @Override
    2.10 +        public void visitClassDef(JCClassDecl tree) {
    2.11 +           if (!inClass) {
    2.12 +               // Do not recurse into nested and inner classes since
    2.13 +               // TransTypes.visitClassDef makes an invocation for each class
    2.14 +               // separately.
    2.15 +               inClass = true;
    2.16 +               try {
    2.17 +                   super.visitClassDef(tree);
    2.18 +               } finally {
    2.19 +                   inClass = false;
    2.20 +               }
    2.21 +           }
    2.22 +        }
    2.23 +
    2.24          private TypeAnnotationPosition resolveFrame(JCTree tree, JCTree frame,
    2.25                  List<JCTree> path, TypeAnnotationPosition p) {
    2.26              switch (frame.getKind()) {
     3.1 --- a/test/tools/javac/typeAnnotations/InnerClass.java	Thu Jul 30 10:30:24 2009 +0100
     3.2 +++ b/test/tools/javac/typeAnnotations/InnerClass.java	Thu Jul 30 10:30:34 2009 +0100
     3.3 @@ -30,9 +30,30 @@
     3.4   */
     3.5  
     3.6  class InnerClass {
     3.7 +
     3.8 +    InnerClass() {}
     3.9 +    InnerClass(Object o) {}
    3.10 +
    3.11      private void a() {
    3.12          new Object() {
    3.13              public <R> void method() { }
    3.14          };
    3.15      }
    3.16 +
    3.17 +    Object f1 = new InnerClass() {
    3.18 +            <R> void method() { }
    3.19 +        };
    3.20 +
    3.21 +    Object f2 = new InnerClass() {
    3.22 +            <@A R> void method() { }
    3.23 +        };
    3.24 +
    3.25 +    Object f3 = new InnerClass(null) {
    3.26 +            <R> void method() { }
    3.27 +        };
    3.28 +
    3.29 +    Object f4 = new InnerClass(null) {
    3.30 +            <@A R> void method() { }
    3.31 +        };
    3.32 +    @interface A { }
    3.33  }

mercurial