JDK-8055063 : Parameter#toString() fails w/ AIOOBE for ctr of inner class w/ generic type
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 8u20
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-08-01
  • Updated: 2015-06-04
  • Resolved: 2014-11-18
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 Other
8u40 b17Fixed 9Fixed naResolved
Related Reports
Blocks :  
Blocks :  
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b23)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b22, mixed mode)

A DESCRIPTION OF THE PROBLEM :
Let there be an non-static inner class with a constructor which has a generic parameter type. Invoking toString() on a j.l.r.Parameter instance representing this parameter fails with an ArrayIndexOutOfBoundsException. As of 1.8.0_20-ea-b23, also Parameter#getAnnotatedType() is effected.

I believe this is related to issue https://bugs.openjdk.java.net/browse/JDK-5087240. I'm creating this separate issue as also getAnnotatedType() is concerned and now not only user code invoking Constructor#getGenericParameterTypes() is affected, but JDK code itself which invokes this method.

Note that getAnnotatedType() used to work as of 1.8.0_11 (the implementation of Executable#getAnnotatedParameterTypes() has changed since then and now also uses getGenericParameterTypes()).


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class ParameterBug {

	public static void main(String[] args) throws Exception {
		Constructor<MyEntity> constructor = MyEntity.class.getConstructor( ReflectionBug.class, Set.class );
		for ( Parameter parameter : constructor.getParameters() ) {
			// the following line raises an AIOOBE for the second parameter
			System.out.println( parameter.toString() );

			// this fails as well
			System.out.println( parameter.getAnnotatedType() );
		}
	}

	public class MyEntity {
		public MyEntity(Set<?> names) {
		}
	}
}
---------- END SOURCE ----------


Comments
not fixed in 8u40 yet
18-11-2014

Out for review
03-11-2014