JDK-8371732 : [redo] Change java.time month/day field types to 'byte'
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.time
  • Affected Version: 26
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-11-12
  • Updated: 2025-11-24
  • Resolved: 2025-11-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 26
26 b25Fixed
Related Reports
CSR :  
Cloners :  
Duplicate :  
Relates :  
Description
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.
Comments
Changeset: cc05530b Branch: master Author: Roger Riggs <rriggs@openjdk.org> Date: 2025-11-14 20:57:20 +0000 URL: https://git.openjdk.org/jdk/commit/cc05530b813564a40c233eaaa80b906795c6d752
14-11-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/28274 Date: 2025-11-12 18:29:52 +0000
12-11-2025