RFR: 8315810: Reimplement ReflectionFactory::newConstructorForSerialization with method handles

Mandy Chung mchung at openjdk.org
Wed Sep 6 18:41:54 UTC 2023


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.

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

Commit messages:
 - Reimplement ReflectionFactory::newConstructorForSerialization with method handle

Changes: https://git.openjdk.org/jdk/pull/15600/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15600&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8315810
  Stats: 162 lines in 10 files changed: 122 ins; 11 del; 29 mod
  Patch: https://git.openjdk.org/jdk/pull/15600.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/15600/head:pull/15600

PR: https://git.openjdk.org/jdk/pull/15600



More information about the security-dev mailing list