JDK-8066092 : java.lang.reflect.Parameter::toString throws exception on certain circumstances
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 8u25
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86_64
  • Submitted: 2014-11-20
  • Updated: 2014-11-27
  • Resolved: 2014-11-27
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux ivostmaina 3.17.1-gentoo-r1 #2 SMP PREEMPT Wed Nov 5 12:40:42 CET 2014 x86_64 AMD FX(tm)-9590 Eight-Core Processor AuthenticAMD GNU/Linux


A DESCRIPTION OF THE PROBLEM :
There are instances of java.lang.reflect.Parameter that throws an IndexOutOfBounds exception when calling toString() method. I appended a Testcase that reproduces the bug allways.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the appended testcase


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import static org.junit.Assert.assertEquals;

import java.lang.reflect.Constructor;
import java.lang.reflect.Parameter;

import org.junit.Test;

public class bug1 {

	@Test
	public void paramter_tostring_exception() 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.getParameters().length);
		Parameter p0 = constructor.getParameters()[0];
		Parameter p1 = constructor.getParameters()[1];

		p0.toString(); // <<<< THROWS INDEX OUT OF BOUNDS EXCEPTION
		p1.toString();
	}

}
---------- END SOURCE ----------


Comments
This is a duplicate of JDK-8055063 - which appears to have been fixed in latest jdk9-dev bits and jdk8u.
27-11-2014

The issue is reproducible with 1.9.0-ea-b22 However, it is the other line where the exception is thrown: p1.toString();
27-11-2014