On Fri, 29 May 2026 14:19:18 GMT, Chen Liang <[email protected]> wrote:

>> src/java.base/share/classes/java/io/ObjectOutputStream.java line 170:
>> 
>>> 168:  *          {@code writeReplace}</a> method can provide a proxy object 
>>> instead. That
>>> 169:  *          object can then be serialized, and used to reconstruct the 
>>> expected value
>>> 170:  *          class instance at deserialization time.
>> 
>> The text in the preview-block aligns with the JEP 401 but I'm wondering how 
>> to read this with java.lang.Integer or other migrated value class as an 
>> example. Suppoer I writeObject an Integer to an ObjectOutputStream when 
>> running with preview features enabled. It appears to serialize it even 
>> though it is a value class and not a record. Maybe there is more in the 
>> serialization spec that I need to read on this?
>> 
>> (The context for asking is really the indirect rather than direct case and 
>> whether there is an issue with migrated value classes or not)
>
> Yes, the serialization spec has special treatment for the 8 wrapper classes.

Okay, so aside from the wrapper classes, and the java.time classes that use the 
serialization proxy pattern, there aren't any other migrated value classes that 
implement Serializable that we need to be concerned about.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/31123#discussion_r3325255088

Reply via email to