an odd case

Steve Sides steve.sides at oracle.com
Wed Mar 6 18:30:41 PST 2013


There are bugs where repeated annotations do not show up. Here's a case 
where it shows up in the wrong place (I think).

If @A and @B are not repeated they show up on the array:
   java.lang.Object[][] i_sa1;
     descriptor: [[Ljava/lang/Object;
     flags:
     RuntimeVisibleTypeAnnotations:
       0: #10(): FIELD
       1: #11(): FIELD
       2: #10(): FIELD, location=[ARRAY]
       3: #11(): FIELD, location=[ARRAY]

However, if repeated, container annotations shows up under the ctor and 
the non-repeated on the field:
   java.lang.Object[][] i_sa1;
     descriptor: [[Ljava/lang/Object;
     flags:
     RuntimeVisibleTypeAnnotations:
       0: #10(): FIELD
       1: #10(): FIELD, location=[ARRAY]

   final Test2 this$0;
     descriptor: LTest2;
     flags: ACC_FINAL, ACC_SYNTHETIC

   Test2$Inner(Test2);
     descriptor: (LTest2;)V
     flags:
     Code:
       stack=2, locals=2, args_size=2
          0: aload_0
          1: aload_1
          2: putfield      #1                  // Field this$0:LTest2;
          5: aload_0
          6: invokespecial #2                  // Method 
java/lang/Object."<init>":()V
          9: aload_0
         10: aconst_null
         11: checkcast     #3                  // class 
"[[Ljava/lang/Object;"
         14: putfield      #4                  // Field 
i_sa1:[[Ljava/lang/Object;
         17: return
       LineNumberTable:
         line 6: 0
         line 7: 9
     RuntimeVisibleTypeAnnotations:
       0: #17(#18=[@#19(),@#19()]): FIELD
       1: #17(#18=[@#19(),@#19()]): FIELD, location=[ARRAY]

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

class Test2<T> {
     class Inner<U> {
            Object  @A @A @B [] @A @A @B [] i_sa1 = null;
     }
}
@Retention(RUNTIME) @Target({TYPE_USE,FIELD})  @Repeatable( AC.class ) 
@interface A { }
@Retention(RUNTIME) @Target({TYPE_USE}) @Repeatable( BC.class ) 
@interface B { }
@Retention(RUNTIME) @Target({TYPE_USE,FIELD})  @interface AC { A[] 
value(); }
@Retention(RUNTIME) @Target({TYPE_USE}) @interface BC { B[] value(); }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/type-annotations-dev/attachments/20130306/11e9dabd/attachment.html 


More information about the type-annotations-dev mailing list