RFR JDK-8181425: Reflection API defend against issues with internal VM derived value type

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri Jun 23 10:15:02 UTC 2017



On 23/06/17 10:32, Tobias Hartmann wrote:
> Hi Mandy,
>
> as I mentioned off-thread, this change breaks the ValueTypeTestBench.java because we rely on MyValue1.class.getDeclaredMethods() [1] to be able to access the declared methods of a value type and set compilation and inlining rules via the Whitebox API. This is crucial for the tests to work. In this case the value type is not derived but it's an VVT declared with "__ByValue".
I'd say we should add a flag to allow reflection on value types - but at 
some point those tests would have to be translated to use VCC/DVT (in 
which case you can do reflection fine by looking at the VCC).

Maurizio
>
> This change also breaks the ValueTypeArray.java test with:
>    Caused by: java.lang.ClassNotFoundException: [Qruntime.valhalla.valuetypes.Point; is a derived value class
> 	  at java.base/java.lang.Class.forName(Class.java:293)
>            at runtime.valhalla.valuetypes.ValueTypeArray.testClassForName(ValueTypeArray.java:62)
> Because the test does Class.forName("[Qruntime.valhalla.valuetypes.Point;").
>
> And DeriveValueTypeCreation.java and VboxUnbox.java fail with:
>    java.lang.InternalError: runtime.valhalla.valuetypes.ValueCapableClass$Value not a value type
> 	at java.base/java.lang.System$2.loadValueTypeClass(System.java:2174)
> 	at java.base/valhalla.shady.MinimalValueTypes_1_0.loadValueTypeClass(MinimalValueTypes_1_0.java:110)
> 	at java.base/valhalla.shady.MinimalValueTypes_1_0.getValueTypeClass(MinimalValueTypes_1_0.java:103)
> 	at java.base/jdk.experimental.value.ValueType.forClass(ValueType.java:152)
> 	at runtime.valhalla.valuetypes.VboxUnbox.testCorrectBoxing(VboxUnbox.java:47)
> 	at runtime.valhalla.valuetypes.VboxUnbox.main(VboxUnbox.java:41)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.base/java.lang.reflect.Method.invoke(Method.java:563)
> 	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:115)
> 	at java.base/java.lang.Thread.run(Thread.java:844)
>
> This is a problem with the C2 intrinsic for java.lang.Class::isAssignableFrom which does not work properly with value types. I'll work on a fix. As temporary workaround you can use -XX:DisableIntrinsic=_isAssignableFrom.
>
> Best regards,
> Tobias
>
> [1] http://hg.openjdk.java.net/valhalla/valhalla/hotspot/file/2552e5001a5d/test/compiler/valhalla/valuetypes/ValueTypeTestBench.java#l2650
>
> On 20.06.2017 22:31, Mandy Chung wrote:
>> http://cr.openjdk.java.net/~mchung/valhalla/webrevs/8181425/webrev.00/index.html
>>
>> This patch changes Class::forName to not to return DVT classes
>> and also disallows reflection API get members of a DVT class.
>> ClassLoader::loadClass should probably be changed and I can
>> fix that separately.
>>
>> I added a couple of new tests and also fix the MVT tests with
>> GPL header rather than GPL+CP header.
>>
>> Mandy
>>



More information about the valhalla-dev mailing list