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

Regression in serialization of LocalDate class objects

XMLWordPrintable

      The serialized form of several `java.time` class objects is incompatible between JDK 25 and previous releases due to a change in the type of the month and day fields.

      The serialized form of LocalDate instances is not affected; the serialized form uses an externalized form in which the stream format is independent of the field types.

      The purpose of the change was to enable packing fields more tightly in anticipation of converting to value classes in the Valhalla project.
      The changed field types result in the serialized form of the classes being incompatible between JDK 25 and previous versions. The change was made in JDK-8334742. The affected class are LocalDate, YearMonth, MonthDay, and HirjahDate.
      When de-serializing, an exception is thrown:

      `java.io.InvalidClassException: java.time.LocalDate; incompatible types for field day
      at java.base/java.io.ObjectStreamClass.matchFields(ObjectStreamClass.java:2077)
      `

            rriggs Roger Riggs
            rriggs Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: