-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
9, 10, 11
-
x86_64
-
generic
A DESCRIPTION OF THE PROBLEM :
If an owner type of a nested parameterized type is annotated, the type annotation is not accessible via the reflection API.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the example code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The type annotation is found for foo and it is found for the correct type for bar.
ACTUAL -
The type annotation is not found for foo and found for the incorrect type for bar.
---------- BEGIN SOURCE ----------
public class Foo {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
@interface SampleTypeAnnotation { }
static class GenericNested<T> {
class Inner { }
}
@SampleTypeAnnotation GenericNested<?>. Inner foo;
GenericNested<?>.@SampleTypeAnnotation Inner bar;
public static void main(String[] args) throws Exception {
Field foo = Foo.class.getDeclaredField("foo");
System.out.println(foo.getAnnotatedType().getType().toString());
System.out.println(foo.getAnnotatedType().getAnnotations().length);
System.out.println(foo.getAnnotatedType().getAnnotatedOwnerType().getType().toString());
System.out.println(foo.getAnnotatedType().getAnnotatedOwnerType().getAnnotations().length);
Field bar = Foo.class.getDeclaredField("bar");
System.out.println(bar.getAnnotatedType().getType().toString());
System.out.println(bar.getAnnotatedType().getAnnotations().length);
System.out.println(bar.getAnnotatedType().getAnnotatedOwnerType().getType().toString());
System.out.println(bar.getAnnotatedType().getAnnotatedOwnerType().getAnnotations().length);
}
}
---------- END SOURCE ----------
FREQUENCY : always
If an owner type of a nested parameterized type is annotated, the type annotation is not accessible via the reflection API.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the example code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The type annotation is found for foo and it is found for the correct type for bar.
ACTUAL -
The type annotation is not found for foo and found for the incorrect type for bar.
---------- BEGIN SOURCE ----------
public class Foo {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
@interface SampleTypeAnnotation { }
static class GenericNested<T> {
class Inner { }
}
@SampleTypeAnnotation GenericNested<?>. Inner foo;
GenericNested<?>.@SampleTypeAnnotation Inner bar;
public static void main(String[] args) throws Exception {
Field foo = Foo.class.getDeclaredField("foo");
System.out.println(foo.getAnnotatedType().getType().toString());
System.out.println(foo.getAnnotatedType().getAnnotations().length);
System.out.println(foo.getAnnotatedType().getAnnotatedOwnerType().getType().toString());
System.out.println(foo.getAnnotatedType().getAnnotatedOwnerType().getAnnotations().length);
Field bar = Foo.class.getDeclaredField("bar");
System.out.println(bar.getAnnotatedType().getType().toString());
System.out.println(bar.getAnnotatedType().getAnnotations().length);
System.out.println(bar.getAnnotatedType().getAnnotatedOwnerType().getType().toString());
System.out.println(bar.getAnnotatedType().getAnnotatedOwnerType().getAnnotations().length);
}
}
---------- END SOURCE ----------
FREQUENCY : always