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

Redundant verification of year in LocalDate::ofEpochDay

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 19
    • None
    • core-libs
    • None
    • b16

      ofEpochDay verifies that the input is in the allowed range for ChronoField.EPOCH_DAY, then after a calculating the year validates that this is in the allowed range for ChronoField.YEAR. ofEpochDay(EPOCH_DAY.getMinimum()) and ofEpochDay(EPOCH_DAY.getMaximum()) both evaluate to dates with a year in the allowed range [-999999999, 999999999] so the runtime validation is redundant.

      To be sure a test that checks that values around and near EPOCH_DAYS range edges throw exceptions as expected with and without the redundant validation should be added.

            redestad Claes Redestad
            redestad Claes Redestad
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: