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

Change java.time month/day field types to 'byte'

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 23
    • core-libs
    • None

      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.

      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.)

      Generally, field type changes are disruptive to serialization, but these classes use a custom Externalizable encoding (see 'readExternal'/'writeExternal') which already stores these values as bytes.

            rriggs Roger Riggs
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: