JDK-8315810 : Reimplement sun.reflect.ReflectionFactory::newConstructorForSerialization with method handles
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 22
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-09-06
  • Updated: 2024-05-23
  • Resolved: 2023-09-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 22
22 b16Fixed
Related Reports
Blocks :  
CSR :  
Duplicate :  
Relates :  
Relates :  
Sub Tasks
JDK-8317113 :  
Description
sun.reflect.ReflectionFactory::newConstructorForSerialization is JDK unsupported API used by 3rd party serialization framework.

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.   See [1] for details.

Reimplementing ReflectionFactory::newConstructorForSerialization with method handles will allow the VM hack to be removed. 

[1] https://bugs.openjdk.org/browse/JDK-8305104?focusedCommentId=14570146&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14570146
Comments
Changeset: 5cea53d3 Author: Mandy Chung <mchung@openjdk.org> Date: 2023-09-14 16:10:55 +0000 URL: https://git.openjdk.org/jdk/commit/5cea53d372744ddf1bedaae4667415e6525ef82f
14-09-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/15600 Date: 2023-09-06 18:34:29 +0000
06-09-2023