-
CSR
-
Resolution: Approved
-
P4
-
None
-
behavioral
-
low
-
Java API
-
SE
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:
- Instances of record classes disallow customization, i.e. the
class-specific
writeObject
,readObject
, andreadObjectNoData
, methods are ignored. - The serialized form of a record is its record components - no customization (see point #1).
- Deserialization of a stream object whose local class equivalent of the specified stream class descriptor is a record class, proceeds through the canonical constructor.
- The requirement to match
serialVersionUID
is waived for records. - Cycles from record component values to the record object itself are not preserved.
- 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
- relates to
-
JDK-8255172 JOSS changes for Record Classes (Final)
-
- Resolved
-