In the following classes, month and day values are stored in fields of type 'int' or 'short'. The range of allowed values is small enough that the type can be 'byte' instead. The dedicated serialized form of each uses byte for the serialized values.
java.time.YearMonth
java.time.MonthDay
java.time.LocalDate
java.time.chono.HijrahDate
Refactoring the type will give the JVM a little more layout flexibility, and will be especially useful when these classes become value classes. (For example, it reduces YearMonth and MonthDay to a payload size smaller than 64 bits, which can be significant.)
In the earlier change (JDK-8334742), changing the primitive type in the serialized class caused a compatibility issue between older and newer JDK versions. The serialized form of the class objects was incompatible.
To retain compatibility of the class object serialized form the field names and types must be explicitly declared using the serialPersistentFields mechanism and the \@serialField declarations.
java.time.YearMonth
java.time.MonthDay
java.time.LocalDate
java.time.chono.HijrahDate
Refactoring the type will give the JVM a little more layout flexibility, and will be especially useful when these classes become value classes. (For example, it reduces YearMonth and MonthDay to a payload size smaller than 64 bits, which can be significant.)
In the earlier change (
To retain compatibility of the class object serialized form the field names and types must be explicitly declared using the serialPersistentFields mechanism and the \@serialField declarations.
- clones
-
JDK-8334742 Change java.time month/day field types to 'byte'
-
- Closed
-
- relates to
-
JDK-8371410 [lworld] LocalDate example isn't being flattened
-
- Open
-
- links to
-
Review(master)
openjdk/jdk/28274