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

Calendar.Builder.build() Throws ArrayIndexOutOfBoundsException

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 25
    • core-libs
    • None
    • behavioral
    • minimal
    • Hide
      Changes an ArrayIndexOutOfBoundsException to an IllegalArgumentException; where the latter is the expected behavior. It is highly unlikely anyone depends on the original exception being an ArrayIndexOutOfBoundsException for this specific case, but it has been long standing behavior regardless. Thus, minimal risk.
      Show
      Changes an ArrayIndexOutOfBoundsException to an IllegalArgumentException; where the latter is the expected behavior. It is highly unlikely anyone depends on the original exception being an ArrayIndexOutOfBoundsException for this specific case, but it has been long standing behavior regardless. Thus, minimal risk.
    • Java API
    • JDK

      Summary

      Prevent ArrayIndexOutOfBoundsException from leaking out when expecting IllegalArgumentException for a Japanese calendar with an era too large.

      Problem

      Building a Japanese calendar via Calendar.Builder with an era too large throws an ArrayIndexOutOfBoundsException, but it is specified to throw an IllegalArgumentException.

      Solution

      Ensure when a Japanese calendar re-computes its time, if an era is too great it will throw an IllegalArgumentException instead of an ArrayIndexOutOfBoundsException. This addresses Calendar.build() for Japanese calendars (which is the bug submitted case), but also affects any Japanese Calendar operations that call Calendar.computeTime(). This behavior is desirable.

      Note that we do not check an era value too small, as historically Japanese calendars ignore such values.

      Specification

      n/a

            jlu Justin Lu
            webbuggrp Webbug Group
            Chen Liang, Naoto Sato
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: