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

Clarify java.time.chrono.Chronology.isLeapYear for out of range years

    Details

    • Subcomponent:
    • Resolved In Build:
      b51
    • Verification:
      Verified

      Backports

        Description

        The spec says that the method isLeapYear(long prolepticYear) accepts as parameter prolepticYear which is not validated for range.

        http://docs.oracle.com/javase/8/docs/api/java/time/chrono/HijrahChronology.html#isLeapYear-long-

        But f.e. in the case of using one of the following values 1004, 1008, 1012, 2000, 400, 4, 400000000, 0, 96, -4, -400000000 as parameter the unexpected DateTimeException is thrown:

        java.time.DateTimeException: Hijrah date out of range


        Tests belonging to the JCK9 suite (not yet integrated) will fail due to this issue: api/java_time/chrono/HijrahChronology/index.html#IsLeapYear

        (not integrated yet)



          Issue Links

            Activity

            Hide
            scolebourne Stephen Colebourne added a comment -
            To meet the spec, I propose that dates outside the supported range return false.
            Show
            scolebourne Stephen Colebourne added a comment - To meet the spec, I propose that dates outside the supported range return false.
            Hide
            rriggs Roger Riggs added a comment - - edited
            All of the other methods that operate on Hijrah dates are checked for a valid range and throw DateTimeException.
            Throwing an exception will prevent an incorrect value (25% of the time) from being returned and propagated into application code.
            The observed ArrayIndexOutOfBoundException is a bug in the year range checking.

            The specification for HijrahChronology should specify that the range of the calendar variants is limited
            by the available calendar data and DateTimeException is thrown if data is not available for a year, month, or day.

            Show
            rriggs Roger Riggs added a comment - - edited All of the other methods that operate on Hijrah dates are checked for a valid range and throw DateTimeException. Throwing an exception will prevent an incorrect value (25% of the time) from being returned and propagated into application code. The observed ArrayIndexOutOfBoundException is a bug in the year range checking. The specification for HijrahChronology should specify that the range of the calendar variants is limited by the available calendar data and DateTimeException is thrown if data is not available for a year, month, or day.
            Hide
            rriggs Roger Riggs added a comment - - edited
            After some discussion, an alternate solution is proposed.
            The java.time.chrono.Chronology.isLeapYear method will be clarified to require correct leap year
            results for the year range supported by the calendar and recommend a best effort value or false
            outside the range.
            Show
            rriggs Roger Riggs added a comment - - edited After some discussion, an alternate solution is proposed. The java.time.chrono.Chronology.isLeapYear method will be clarified to require correct leap year results for the year range supported by the calendar and recommend a best effort value or false outside the range.
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/1f2da3273bd8
            User: rriggs
            Date: 2015-02-06 22:29:46 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/1f2da3273bd8 User: rriggs Date: 2015-02-06 22:29:46 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/1f2da3273bd8
            User: lana
            Date: 2015-02-18 23:14:17 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/1f2da3273bd8 User: lana Date: 2015-02-18 23:14:17 +0000

              People

              • Assignee:
                rriggs Roger Riggs
                Reporter:
                ostrizhe Olga Strizhenko (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: