type-annotations in inner in anonymous class

Steve Sides steve.sides at oracle.com
Mon Apr 8 14:32:40 PDT 2013

Hi Werner,
I have a build of the latest type-annotations compiler. The crash bug(s) 
are fixed and it all compiles and runs(yeah!).  After verifying my 
expected valures, I will be able to put back a last test using inner and 
anonymous classes. In the meantime, I see in the case below that no type 
annotations are attributed to the methods and fields in InnerAnon, only 
Runtime(In)VisibleAnnotations.  The cases for inner, local and anonymous 
classes are okay, but the inner class in an anonymous class (not sure 
how likely that is, but here it is) are failing.


import java.lang.annotation.*;
import static java.lang.annotation.RetentionPolicy.*;
import static java.lang.annotation.ElementType.*;

class Test1IA<T> {
     Object mtest( Test1IA<T> t){ return null;  }
     public void test() {
         mtest( new Test1IA<T>() {
                 class InnerAnon<U> { // TestN$1$InnerAnon.class
                     @A @B @C @D  String ia_odata1 = "test";
                     @A @B @C @D  int    ia_pdata1 = 0;
                     @A @B @C @D  U      ia_udata = null;
                     @A @B @C @D  Object [][] ia_sa1 = null;
                     @TA @TB @C @D  T    ia_tdata = null;
                     @A @B @C @D  String ia_m1(){ return null; };
                     @A @B @C @D  int    ia_m2(@A @B @C @D  Object 
o){return 0;}
                     @A @B @C @D
<@TA @TB @C @D  U> Object ia_um(@A @B @C @D   U u) { return null; }
                 InnerAnon<String> IA = new InnerAnon< String>();

@Retention(RUNTIME) @Target({TYPE_USE,FIELD})  @Repeatable( AC.class ) 
@interface A { }
@Retention(RUNTIME) @Target({TYPE_USE,METHOD}) @Repeatable( BC.class ) 
@interface B { }
@Retention(RUNTIME) @Target({TYPE_USE,FIELD})  @interface AC { A[] 
value(); }
@Retention(RUNTIME) @Target({TYPE_USE,METHOD}) @interface BC { B[] 
value(); }

@Retention(CLASS)   @Target({TYPE_USE,FIELD})  @Repeatable( CC.class ) 
@interface C { }
@Retention(CLASS)   @Target({TYPE_USE,METHOD}) @Repeatable( DC.class ) 
@interface D { }
@Retention(CLASS)   @Target({TYPE_USE,FIELD})  @interface CC { C[] 
value(); }
@Retention(CLASS)   @Target({TYPE_USE,METHOD}) @interface DC { D[] 
value(); }

@Repeatable( TAC.class ) @interface TA { }
@Repeatable( TBC.class ) @interface TB { }
@Retention(RUNTIME) @Target({TYPE_USE,TYPE_PARAMETER,FIELD})  @interface 
TAC { TA[] value(); }
@Retention(RUNTIME) @Target({TYPE_USE,TYPE_PARAMETER,METHOD}) @interface 
TBC { TB[] value(); }

More information about the type-annotations-dev mailing list