-
Bug
-
Resolution: Fixed
-
P2
-
repo-valhalla
Currently, when asking the Reflection API for an accessor to a the constructor of j.l.Object, the instance being returned is an InstantiationExceptionConstructorAccessorImpl. Instances of this class throw an InstantiationException on any attempt to instantiate the class they provide access to.
To align the behavior of the Reflection API with the new semantic of the 'new' bytecode, the API should perform the same class substitution as the VM does.
An example of the issue can be see in test java/beans/Introspector/OverriddenGenericSetter.java which fails with the following stack trace:
java.lang.InstantiationException
at java.base/jdk.internal.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)
at OverriddenGenericSetter.testBehaviour(OverriddenGenericSetter.java:85)
at OverriddenGenericSetter.main(OverriddenGenericSetter.java:65)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
at java.base/java.lang.Thread.run(Thread.java:833)
JavaTest Message: Test threw exception: java.lang.InstantiationException