Draft Object Serialization Specification for records - update

Chris Hegarty chris.hegarty at oracle.com
Tue Oct 22 12:34:46 UTC 2019


Hi Peter,

Thanks for following up on this.

> On 22 Oct 2019, at 09:57, Peter Levart <peter.levart at gmail.com> wrote:
> 
> Hi Chris,
> 
> On 10/15/19 1:28 PM, Chris Hegarty wrote:
>> Please find a link to an updated draft serialization spec for records.
>> This version contains all comments and feedback so far.
>> 
>> https://cr.openjdk.java.net/~chegar/records/spec/records-serialization.04.html
>> 
>> * Updated to reflect the new Class::getRecordComponents
>> * For migration from a record class to a record-like class, a record may declare serialVersionUID, which is effectively ignored when local class equivalent of the specified stream class descriptor is a record class
> I don't see this in the text. Specifically in 1.13. the text says:
> 
> "Any serialPersistentFields or serialVersionUID field declarations are also ignored -- all record classes have a fixed serialVersionUID of 0L."
> 
> And in 4.6. it says:
> 
> "The serialVersionUID for dynamic proxy classes, enum types, and record classes, is always the value 0L."
> 
> Also the implementation of records serialization proposed on core-libs-dev by Vincente is alligned with this text.
> 
> 
> I note that enums took an approach where their serialVersionUID is always 0L, but their serialization format is also very different than that of any enum-like class. Cross-serialization compatibility between enum-like class and enum was not a goal then.
> 
> If records vs. record-like classes have a goal of Cross-serialization compatibility, then explicit serialVersionUID static final field on records must be respected during serialization, but can be ignored during deserialization to enable later removing of the static field when migration from record-like class is finally complete.

Apologies ( the change never made it through ), you are of course correct.

Here is an updated version of the spec with sections 1.13 “Serialization of Records”, and section 4.6 “Stream Unique Identifiers” updated:

  https://cr.openjdk.java.net/~chegar/records/spec/records-serialization.05.html

The implementation in the records branch has been aligned with the updated spec:

  https://hg.openjdk.java.net/amber/amber/rev/52a9226db842

-Chris.




More information about the amber-spec-experts mailing list