-
Bug
-
Resolution: Fixed
-
P4
-
8
-
b117
-
Verified
See the thread "references to non-static types from annotations" at http://mail.openjdk.java.net/pipermail/compiler-dev/2016-April/010104.html.
In a nutshell, @A(I.class) in the source below is legal, but javac generates a invalid RuntimeVisibleAnnotations attribute for it. javac is effectively interpreting the annotation as @A(Test<T>.I.class) but should interpret it as @A(Test.I.class), which compiles correctly when written in source by hand.
class Test<T> {
@Retention(RetentionPolicy.RUNTIME) @interface A { Class<?> value(); }
// A nested interface is static. The annotation refers to a non-static class.
@A(I.class) interface C {}
class I {}
}
In a nutshell, @A(I.class) in the source below is legal, but javac generates a invalid RuntimeVisibleAnnotations attribute for it. javac is effectively interpreting the annotation as @A(Test<T>.I.class) but should interpret it as @A(Test.I.class), which compiles correctly when written in source by hand.
class Test<T> {
@Retention(RetentionPolicy.RUNTIME) @interface A { Class<?> value(); }
// A nested interface is static. The annotation refers to a non-static class.
@A(I.class) interface C {}
class I {}
}
- duplicates
-
JDK-8218659 getAnnotations crashes with ClassCastException
-
- Closed
-