On Fri, 5 Jun 2026 14:06:55 GMT, Chen Liang <[email protected]> wrote:

>> ReflectionFactory.newConstructorForSerializatoin might bypass strict 
>> initialization. We should make sure the skipped classes in the constructor 
>> chain do not declare strict instance fields.
>> 
>> This updates the specification of jdk.unsupported's ReflectionFactory to 
>> reflect this behavioral update.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Chen Liang has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Apply suggestions from code review
>   
>   Co-authored-by: Viktor Klang <[email protected]>

src/jdk.unsupported/share/classes/sun/reflect/ReflectionFactory.java line 77:

> 75:      *         strictly-initialized fields
> 76:      */
> 77:     public Constructor<?> newConstructorForSerialization(Class<?> cl,

The 1-arg newConstructorForSerialization returns null, the 2-arg 
newConstructorForSerialization may return null or throw UOE. Is that existing 
behavior (before value classes and strict-init fields), just checking.

(although this is the jdk.unsupported module, the ReflectionFactory "API" is 
there for 3rd party serialization libraries to continue to work until legacy 
serialization goes away)

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2350#discussion_r3363810127

Reply via email to