-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
8
-
None
According to the spec for j.l.r.WildcardType:
"Note that if no upper bound is explicitly declared, the upper bound is
Object."
And looks like this should be also true for j.l.r.AnnotatedWildcardType.
If we have wildcard without definition of lower and upper
bounds, AnnotatedWildcardType.getAnnotatedUpperBounds().length will
return 1.
Minimized test:
-------------------------------------------------------------------------------
public class Test {
public Test(List<? super String> p) {}
public static void main(String[] args) throws NoSuchMethodException {
Constructor constructor = Test.class.getConstructor(List.class);
AnnotatedParameterizedType at = (AnnotatedParameterizedType)
constructor.getAnnotatedParameterTypes()[0];
System.out.println(((AnnotatedWildcardType)
at.getAnnotatedActualTypeArguments()[0]).getAnnotatedUpperBounds().length);
ParameterizedType t = (ParameterizedType)
constructor.getGenericParameterTypes()[0];
System.out.println(((WildcardType)
t.getActualTypeArguments()[0]).getUpperBounds().length);
}
}
-------------------------------------------------------------------------------
Output (tested with jdk8u20):
-------------------------------------------------------------------------------
0
1
-------------------------------------------------------------------------------
As I understand output should be:
-------------------------------------------------------------------------------
1
1
-------------------------------------------------------------------------------
"Note that if no upper bound is explicitly declared, the upper bound is
Object."
And looks like this should be also true for j.l.r.AnnotatedWildcardType.
If we have wildcard without definition of lower and upper
bounds, AnnotatedWildcardType.getAnnotatedUpperBounds().length will
return 1.
Minimized test:
-------------------------------------------------------------------------------
public class Test {
public Test(List<? super String> p) {}
public static void main(String[] args) throws NoSuchMethodException {
Constructor constructor = Test.class.getConstructor(List.class);
AnnotatedParameterizedType at = (AnnotatedParameterizedType)
constructor.getAnnotatedParameterTypes()[0];
System.out.println(((AnnotatedWildcardType)
at.getAnnotatedActualTypeArguments()[0]).getAnnotatedUpperBounds().length);
ParameterizedType t = (ParameterizedType)
constructor.getGenericParameterTypes()[0];
System.out.println(((WildcardType)
t.getActualTypeArguments()[0]).getUpperBounds().length);
}
}
-------------------------------------------------------------------------------
Output (tested with jdk8u20):
-------------------------------------------------------------------------------
0
1
-------------------------------------------------------------------------------
As I understand output should be:
-------------------------------------------------------------------------------
1
1
-------------------------------------------------------------------------------
- duplicates
-
JDK-8054304 Clarify treatment of bounds in j.l.r.Annotated{WildcardType,TypeVariable}
-
- Closed
-
- relates to
-
JDK-8058595 annotatedWildcardTypeLowerBoundTest on all platforms
-
- Closed
-
-
JDK-8054304 Clarify treatment of bounds in j.l.r.Annotated{WildcardType,TypeVariable}
-
- Closed
-