JDK-8039916 : AnnotatedType.getType() of a Executable parameters may return wrong type
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2014-04-03
  • Updated: 2014-12-22
  • Resolved: 2014-06-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u20Fixed 9 b17Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
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


Comments
Not a regression since this API was introduced in 8.
13-05-2014

Letting dev team decide how to treat this webbug.
10-04-2014