RFR: 8315810: Reimplement sun.reflect.ReflectionFactory::newConstructorForSerialization with method handles
ExE Boss
duke at openjdk.org
Wed Sep 6 19:53:41 UTC 2023
On Wed, 6 Sep 2023 19:47:19 GMT, Mandy Chung <mchung at openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 3534:
>>
>>> 3532: * This method is only used to implement the unsupported
>>> 3533: * sun.reflect.ReflectionFactory::newConstructorForSerialization API.
>>> 3534: */
>>
>> The following is probably more correct:
>> Suggestion:
>>
>> /**
>> * Produces a method handle that is capable of creating instances of the given class
>> * and instantiated by the given constructor. No security manager check.
>> *
>> * This method is used to implement serialization and the unsupported
>> * sun.reflect.ReflectionFactory::newConstructorForSerialization API.
>> */
>
> What are you referring to "to implement serialization"? It's only used by ReflectionFactory.
It’s called from the implementation of `JavaLangInvokeAccess::serializableConstructor`, which is called by `jdk.internal.reflect.ReflectionFactory::newConstructorForSerialization`, which is called by `java.io.ObjectStreamClass::getSerializableConstructor`:
https://github.com/openjdk/jdk/blob/86a18f5e2e0825dddb77656b2f43f64684f1464c/src/java.base/share/classes/java/io/ObjectStreamClass.java#L1444-L1446
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15600#discussion_r1317753943
More information about the core-libs-dev
mailing list