-
Bug
-
Resolution: Fixed
-
P4
-
8, 9, 10, 11
-
b16
-
x86_64
-
generic
-
Verified
A DESCRIPTION OF THE PROBLEM :
Type annotations on type variable bounds are not detected if the bounds are themselves type variables.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code example for a demonstration of the behavior.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The type annotations of both type variable bounds are detected.
ACTUAL -
The type annotations of a type variable that is bound by another type variable is not detected.
---------- BEGIN SOURCE ----------
public class Foo {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
@interface SampleTypeVariable { }
<T, S extends @SampleTypeVariable T, U extends @SampleTypeVariable Object> void foo() { }
public static void main(String[] args) throws Exception {
Method foo = Foo.class.getDeclaredMethod("foo");
TypeVariable<Method>[] typeParameters = foo.getTypeParameters();
TypeVariable<?> s = typeParameters[1];
AnnotatedType[] annotatedBoundsOfS = s.getAnnotatedBounds();
System.out.println(annotatedBoundsOfS[0].getDeclaredAnnotations().length);
TypeVariable<?> u = typeParameters[2];
AnnotatedType[] annotatedBoundsOfU = u.getAnnotatedBounds();
System.out.println(annotatedBoundsOfU[0].getDeclaredAnnotations().length);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None.
FREQUENCY : always
Type annotations on type variable bounds are not detected if the bounds are themselves type variables.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the code example for a demonstration of the behavior.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The type annotations of both type variable bounds are detected.
ACTUAL -
The type annotations of a type variable that is bound by another type variable is not detected.
---------- BEGIN SOURCE ----------
public class Foo {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
@interface SampleTypeVariable { }
<T, S extends @SampleTypeVariable T, U extends @SampleTypeVariable Object> void foo() { }
public static void main(String[] args) throws Exception {
Method foo = Foo.class.getDeclaredMethod("foo");
TypeVariable<Method>[] typeParameters = foo.getTypeParameters();
TypeVariable<?> s = typeParameters[1];
AnnotatedType[] annotatedBoundsOfS = s.getAnnotatedBounds();
System.out.println(annotatedBoundsOfS[0].getDeclaredAnnotations().length);
TypeVariable<?> u = typeParameters[2];
AnnotatedType[] annotatedBoundsOfU = u.getAnnotatedBounds();
System.out.println(annotatedBoundsOfU[0].getDeclaredAnnotations().length);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None.
FREQUENCY : always
- duplicates
-
JDK-8202473 (ann) A type variable with multiple bounds does not correctly place type annotation
- Closed
- relates to
-
JDK-8146862 Example of wrong type annotation indexing of type varaible bounds on recursive type
- Closed
-
JDK-8246804 Incorrect copyright header in TypeAnnotationParser.java
- Resolved