JDK-8256661 : Apply the preview-related record changes to the JOSS
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.io:serialization
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 16
  • Submitted: 2020-11-19
  • Updated: 2020-12-18
  • Resolved: 2020-11-24
Related Reports
Relates :  
Description
Summary
-------

Add record specific support to the Java Object Stream Specification
(JOSS).

Problem
-------

Record classes are a final feature in Java 16. This CSR covers the
aspects of record classes as they apply to the JOSS.

Note: API clarifications to `ObjectInputStream` (and related SE Platform
APIs) are handled by a separate issue (JDK-8256679).

Solution
--------

Update the JOSS to specify how record classes are handled.
High-level outline follows:

1. Instances of record classes disallow customization, i.e. the
   class-specific `writeObject`, `readObject`, and `readObjectNoData`,
   methods are ignored.
2. The serialized form of a record is its record components - no
   customization (see point #1).
3. Deserialization of a stream object whose local class equivalent of
   the specified stream class descriptor is a record class, proceeds
   through the canonical constructor.
4. The requirement to match `serialVersionUID` is waived for records.
5. Cycles from record component values to the record object itself are
   not preserved.
6. Types of compatible changes for record classes are listed.

A new section, 1.14 "Circular References", is added to better describe
how existing circular references are handled, to then later contrast
to how circular references are handled for records.

Note: There is no change to the Object Serialization Stream Protocol.

Specification
-------------

The changes proposed, for inclusion in the JOSS for Java 16, are
identical to that of what previewed in Java 15. As such, the Java 15
preview-related record JOSS spec change doc is attached (or viewable
online at [1]) - since the spec change doc is the most readable form
of the actual changes.

[1] https://docs.oracle.com/en/java/javase/15/docs/specs/records-serialization.html

Comments
Moving to Approved.
24-11-2020

Moving to Provisional.
23-11-2020