-
Bug
-
Resolution: Fixed
-
P3
-
8
-
b17
-
x86_64
-
linux
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8048418 | 8u25 | Joel Borggrén-Franck | P3 | Resolved | Fixed | b05 |
JDK-8043032 | 8u20 | Joel Borggrén-Franck | P3 | Resolved | Fixed | b20 |
JDK-8053676 | emb-8u26 | Joel Borggrén-Franck | P3 | Resolved | Fixed | b17 |
build 1.8.0-b132
ADDITIONAL OS VERSION INFORMATION :
Linux ivostmaina 3.13.6-gentoo #1 SMP Thu Mar 20 02:22:16 CET 2014 x86_64 AMD FX(tm)-8350 Eight-Core Processor AuthenticAMD GNU/Linux
A DESCRIPTION OF THE PROBLEM :
This Bug maybe related to Bug: https://bugs.openjdk.java.net/browse/JDK-8038994
If getAnnotatedParameterTypes() is used on an Exectuable instance (Method or Constructor) which have got generic type parameters, the returned AnnotatedType.getType() may return the class type instead of a ParameterizedType instance. getGenericParameterTypes() returns the right types.
For all i, I expect
Exectuable.getAnnotatedParameterTypes()[i].getType() equals Exectuable.getGenericParameterTypes()[i]
Example:
class TestClass {
void foobar(List<T> x);
}
Method m; is the reflection object for method "foobar"
m.getAnnotatedParameterTypes[0].getType() returns List.class instead of an instance to a ParameterizedType instance
m.getGenericParameterTypes()[0] returns as expected a ParameterizedType instance
REGRESSION. Last worked in version 8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
see test case
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
@Test
public void java8_executable_getAnnotatedParameterTypes_v1()
throws NoSuchMethodException, SecurityException {
class MyClass<T> {
}
class MySecondClass<T> {
@SuppressWarnings("unused")
public MyClass<T> get(MyClass<T> p) {
return p;
}
}
Method method = MySecondClass.class.getMethod("get", MyClass.class);
AnnotatedType at = method.getAnnotatedParameterTypes()[0];
// at.getType() is MyClass.class in build 1.8.0-b132
Type t = method.getGenericParameterTypes()[0];
// t is ParameterizedType of MyClass
assertEquals(t, at.getType());
assertEquals(at.getType(), t);
}
---------- END SOURCE ----------
SUPPORT :
YES
- backported by
-
JDK-8043032 AnnotatedType.getType() of a Executable parameters may return wrong type
- Resolved
-
JDK-8048418 AnnotatedType.getType() of a Executable parameters may return wrong type
- Resolved
-
JDK-8053676 AnnotatedType.getType() of a Executable parameters may return wrong type
- Resolved
- relates to
-
JDK-8044629 (reflect) Constructor.getAnnotatedReceiverType() returns wrong value
- Closed
-
JDK-8057898 Annotations on receiver type's type arguments are lost
- Open
-
JDK-8058220 (reflect) no type annotations on a Parameter representing the annotated receiver
- Open