RFR: 8315810: Reimplement sun.reflect.ReflectionFactory::newConstructorForSerialization with method handles

ExE Boss duke at openjdk.org
Wed Sep 6 19:27:38 UTC 2023


On Wed, 6 Sep 2023 18:34:29 GMT, Mandy Chung <mchung at openjdk.org> wrote:

> This reimplements `sun.reflect.ReflectionFactory::newConstructorForSerialization` with method handles.
> 
> This API currently generates the bytecode which fails the verification because `new C; invokespecial A()` where the given class `C` and invoke a no-arg constructor of `C`'s first non-`Serializable` superclass `A` is not a valid operation per the VM specification. VM special cases the classes generated for reflection to skip verification for the constructors generated for serialization and externalization.  This change will allow such VM hack to be removed.
> 
> A `jdk.reflect.useOldSerializableConstructor` system property can be set to use the old implementation in case if customers run into any compatibility issue.   I expect this change has very low compatibility risk.   This system property is undocumented and will be removed in a future release.

See also: [JDK‑8307575] ([GH‑13853])

[JDK‑8307575]: https://bugs.openjdk.org/browse/JDK-8307575 "[JDK‑8307575] Migrate the serialization constructor accessors to Method Handles"
[GH‑13853]: https://github.com/openjdk/jdk/pull/13853

-------------

PR Comment: https://git.openjdk.org/jdk/pull/15600#issuecomment-1708962019


More information about the core-libs-dev mailing list