bug in attribution of annotations in anonymous classes

Steve Sides steve.sides at oracle.com
Wed Jan 16 14:40:32 PST 2013


Hi Werner,
While writing tests, I looking at type-annotations on type usage in 
anonymous classes and found what looks like a bug.
When compiling the code below, the field 'data' has 2 
RuntimeVisibleTypeAnnotations, while the field in the anonymous class, 
'data2', has3 RuntimeVisibleTypeAnnotations.
If there are 2 (such as @A @B data2) it has 6 (rather than 4). The same 
is true for methods. Test cases are attached.

Can you check this out?

8<- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

     class testclass {
         @C String data = "test";
         void mtest( testclass t){ }
         public void test() {
             mtest( new testclass() {
                      @D String data2 = "test";
                 });
         }
     }

     @Retention(RUNTIME)
     @Target({TYPE_USE,FIELD})
     @interface C { }

     @Retention(RUNTIME)
     @Target({TYPE_USE,FIELD})
     @interface D {

8<- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

thanks,
steve
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: TestAnonInnerMethod.java
Url: http://mail.openjdk.java.net/pipermail/type-annotations-dev/attachments/20130116/4991de8a/TestAnonInnerMethod.java 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: TestAnonInnerField.java
Url: http://mail.openjdk.java.net/pipermail/type-annotations-dev/attachments/20130116/4991de8a/TestAnonInnerField.java 


More information about the type-annotations-dev mailing list