Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8256661

Apply the preview-related record changes to the JOSS

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 16
    • core-libs
    • 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:

      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

            chegar Chris Hegarty
            chegar Chris Hegarty
            Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: