-
Bug
-
Resolution: Duplicate
-
P4
-
8
If class InnerAnnon is instanciated, type annotations on ia_m1() are incorrectly written to classfile.
They are all written as Runtime(In)VisibleAnnotations,
RuntimeVisibleAnnotations:
0: #16()
1: #17()
RuntimeInvisibleAnnotations:
0: #19()
1: #20()
If the declaration for IA is commented out, they are written as expected:
RuntimeVisibleAnnotations:
0: #16()
RuntimeInvisibleAnnotations:
0: #18()
RuntimeVisibleTypeAnnotations:
0: #20(): METHOD_RETURN
1: #16(): METHOD_RETURN
RuntimeInvisibleTypeAnnotations:
0: #22(): METHOD_RETURN
1: #18(): METHOD_RETURN
Compile this as Test1.java and run javap -v Test1$1$InnerAnon
import java.lang.annotation.*;
import static java.lang.annotation.RetentionPolicy.*;
import static java.lang.annotation.ElementType.*;
import java.util.List;
class Test1<T> {
Object mtest( Test1<T> t){ return null; }
Object mmtest( Test1<T> t){ return null; }
public void test() {
mtest( new Test1<T>() {
class InnerAnon<U> { // Test1$1$InnerAnon.class
@A @B @C @D String ia_m1(){ return null; };
}
//If this is commented out, annotations are attributed correctly
InnerAnon<String> IA = new InnerAnon< String>();
});
}
}
@Retention(RUNTIME) @Target({TYPE_USE,FIELD}) @interface A { }
@Retention(RUNTIME) @Target({TYPE_USE,METHOD}) @interface B { }
@Retention(CLASS) @Target({TYPE_USE,FIELD}) @interface C { }
@Retention(CLASS) @Target({TYPE_USE,METHOD}) @interface D { }
They are all written as Runtime(In)VisibleAnnotations,
RuntimeVisibleAnnotations:
0: #16()
1: #17()
RuntimeInvisibleAnnotations:
0: #19()
1: #20()
If the declaration for IA is commented out, they are written as expected:
RuntimeVisibleAnnotations:
0: #16()
RuntimeInvisibleAnnotations:
0: #18()
RuntimeVisibleTypeAnnotations:
0: #20(): METHOD_RETURN
1: #16(): METHOD_RETURN
RuntimeInvisibleTypeAnnotations:
0: #22(): METHOD_RETURN
1: #18(): METHOD_RETURN
Compile this as Test1.java and run javap -v Test1$1$InnerAnon
import java.lang.annotation.*;
import static java.lang.annotation.RetentionPolicy.*;
import static java.lang.annotation.ElementType.*;
import java.util.List;
class Test1<T> {
Object mtest( Test1<T> t){ return null; }
Object mmtest( Test1<T> t){ return null; }
public void test() {
mtest( new Test1<T>() {
class InnerAnon<U> { // Test1$1$InnerAnon.class
@A @B @C @D String ia_m1(){ return null; };
}
//If this is commented out, annotations are attributed correctly
InnerAnon<String> IA = new InnerAnon< String>();
});
}
}
@Retention(RUNTIME) @Target({TYPE_USE,FIELD}) @interface A { }
@Retention(RUNTIME) @Target({TYPE_USE,METHOD}) @interface B { }
@Retention(CLASS) @Target({TYPE_USE,FIELD}) @interface C { }
@Retention(CLASS) @Target({TYPE_USE,METHOD}) @interface D { }
- duplicates
-
JDK-8008762 Type annotation on inner class in anonymous class show up as regular type annotations
- Closed