-
Bug
-
Resolution: Duplicate
-
P4
-
8, 9, 10, 11
-
b17
-
x86_64
-
generic
A DESCRIPTION OF THE PROBLEM :
If two type annotations are placed on two bounds, the reflection API does not consider the bound's index such that an exception is thrown when the reflection API parses the annotations.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the example code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception is thrown and the type annotations are returned correctly.
ACTUAL -
An exception is thrown.
---------- BEGIN SOURCE ----------
public class Foo<T extends Callable<@Foo.SampleTypeAnnotation ?> & List<@Foo.SampleTypeAnnotation ?>> {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
@interface SampleTypeAnnotation { }
public static void main(String[] args) throws Exception {
TypeVariable<Class<Foo>>[] variables = Foo.class.getTypeParameters();
AnnotatedType[] bounds = variables[0].getAnnotatedBounds();
System.out.println(bounds[0] instanceof AnnotatedParameterizedType);
AnnotatedParameterizedType callable = (AnnotatedParameterizedType) bounds[0];
callable.getAnnotatedActualTypeArguments(); // throws exception
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None.
FREQUENCY : always
If two type annotations are placed on two bounds, the reflection API does not consider the bound's index such that an exception is thrown when the reflection API parses the annotations.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the example code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception is thrown and the type annotations are returned correctly.
ACTUAL -
An exception is thrown.
---------- BEGIN SOURCE ----------
public class Foo<T extends Callable<@Foo.SampleTypeAnnotation ?> & List<@Foo.SampleTypeAnnotation ?>> {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
@interface SampleTypeAnnotation { }
public static void main(String[] args) throws Exception {
TypeVariable<Class<Foo>>[] variables = Foo.class.getTypeParameters();
AnnotatedType[] bounds = variables[0].getAnnotatedBounds();
System.out.println(bounds[0] instanceof AnnotatedParameterizedType);
AnnotatedParameterizedType callable = (AnnotatedParameterizedType) bounds[0];
callable.getAnnotatedActualTypeArguments(); // throws exception
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None.
FREQUENCY : always
- duplicates
-
JDK-8146854 Issues with Type annotations on parameters of multiple type variable bound types
- Closed
-
JDK-8202469 (ann) Type annotations on type variable bounds that are also type variables are lost
- Closed
- links to
-
Review openjdk/jdk/155