JDK-8039918 : Constructor.getGenericParameterTypes() with wrong number of parameters
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86_64
  • Submitted: 2014-04-03
  • Updated: 2014-04-10
  • Resolved: 2014-04-10
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)


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 :
Constructor.getGenericParameterTypes() returns the wrong number of parameters if the Constructor instance is a constructor of an inner class. Constructor.getAnnotatedParameterTypes() returns the right number of types.

Example:
see test case

REGRESSION.  Last worked in version 8


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
	@Test
	public void java8_constructor_getGenericParameterTypes_v1()
			throws NoSuchMethodException, SecurityException {

		class OuterClass {

			class GenericClass<T> {

			}

			class InnerClass<T> {

				@SuppressWarnings("unused")
				public InnerClass(GenericClass<T> p) {
				}

			}
		}

		@SuppressWarnings("rawtypes")
		Constructor<OuterClass.InnerClass> constructor = OuterClass.InnerClass.class
				.getConstructor(OuterClass.class, OuterClass.GenericClass.class);

		assertEquals(2, constructor.getGenericParameterTypes().length);
	}
---------- END SOURCE ----------

SUPPORT :
YES


Comments
Closing this issue as a duplicate of JDK-5087240.
10-04-2014

This is not a regression, the behavior is consistent across jdk6, 7 and 8. I'm not sure why getGenericParameterTypes() would return 2 in the test case above? Should it count a reference to the OuterClass instance?
10-04-2014