- 
    Bug 
- 
    Resolution: Not an Issue
- 
     P2 P2
- 
    None
- 
    8
                    Spec for j.l.r.TypeVariable.getAnnotatedBounds() says:
"Returns an array of length 0 if the type parameter declares no bounds."
The following minimized test shows that if the type parameter declares no bounds, the methods returns array of length 1:
-----------------------------------------------------------------------------------------
public class Test {
public static void main(String[] args) {
AnnotatedTypeVariable atv = (AnnotatedTypeVariable) ((AnnotatedParameterizedType) Cls.class.getAnnotatedInterfaces()[0])
.getAnnotatedActualTypeArguments()[0];
TypeVariable tv = (TypeVariable) atv.getType();
// should return an empty array
// Assertion: "Returns an array of length 0 if the type parameter declares no bounds."
AnnotatedType[] aBounds = tv.getAnnotatedBounds();
System.out.println(aBounds.length);
System.out.println(aBounds[0].getType());
}
}
interface Intf<T> {}
class Cls<T> implements Intf<T> {}
-----------------------------------------------------------------------------------------
Output will be:
-----------------------------------------------------------------------------------------
1
class java.lang.Object
1
class java.lang.Object
-----------------------------------------------------------------------------------------
Output should be:
-----------------------------------------------------------------------------------------
1
class java.lang.Object
0
...ArrayIndexOutOfBoundsException...
-----------------------------------------------------------------------------------------
Tested with 8u20
"Returns an array of length 0 if the type parameter declares no bounds."
The following minimized test shows that if the type parameter declares no bounds, the methods returns array of length 1:
-----------------------------------------------------------------------------------------
public class Test {
public static void main(String[] args) {
AnnotatedTypeVariable atv = (AnnotatedTypeVariable) ((AnnotatedParameterizedType) Cls.class.getAnnotatedInterfaces()[0])
.getAnnotatedActualTypeArguments()[0];
TypeVariable tv = (TypeVariable) atv.getType();
// should return an empty array
// Assertion: "Returns an array of length 0 if the type parameter declares no bounds."
AnnotatedType[] aBounds = tv.getAnnotatedBounds();
System.out.println(aBounds.length);
System.out.println(aBounds[0].getType());
}
}
interface Intf<T> {}
class Cls<T> implements Intf<T> {}
-----------------------------------------------------------------------------------------
Output will be:
-----------------------------------------------------------------------------------------
1
class java.lang.Object
1
class java.lang.Object
-----------------------------------------------------------------------------------------
Output should be:
-----------------------------------------------------------------------------------------
1
class java.lang.Object
0
...ArrayIndexOutOfBoundsException...
-----------------------------------------------------------------------------------------
Tested with 8u20
- relates to
- 
                    JDK-8054304 Clarify treatment of bounds in j.l.r.Annotated{WildcardType,TypeVariable} -           
- Closed
 
-