On Fri, 6 Mar 2026 19:08:56 GMT, Vicente Romero <[email protected]> wrote:
>>> Do value classes need any distinct serialVersionUID handling? >> >> Value classes have the same requirements (non-requirements) as identity >> classes. >> They are used to confirm the match between the class and the serialized >> stream contents. >> Migrated value classes especially need the value class and identity class to >> have the same SVUID. > > Oh I see, thanks @RogerRiggs for your answer. I didn't know that specific > about migrated value classes. I will add a comment Formally, use of the proxy pattern is recommended for value classes. Where-in, the `writeReplace` method is invoked to provide the proxy object to be serialized. A record is recommended since it has a stable nominative serialized form. When the proxy object is deserialized, its `readReplace` is invoked to construct the object. The Valhalla `ObjectOutputStream` and `ObjectInputStream` describe the process. (Maybe more words are needed). For migrated java.base classes there is a private protocol implemented in ObjectInputStream to use a constructor of each class to create the value objects from the field values extracted from the serialized form. The spec in this area is weak and vague, since it is not intended for general use. More work is needed in this area of the spec. ------------- PR Review Comment: https://git.openjdk.org/valhalla/pull/2187#discussion_r2897553464
