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

java.util.GregorianCalendar.roll(int field, boolean up) fails with illegal field

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2fcs
    • CPU:
      sparc
    • OS:
      solaris_2.5
    • Verification:
      Verified

      Description



      Name: dfC67450 Date: 05/27/98



      java.util.GregorianCalendar.roll(int field, boolean up) throws ArrayIndexOutOfBounds
      instead of IllegalArgument exception when field < 0 or field >= FIELD_COUNT.
      Javadoc says about roll(int field, boolean up) :

           exception: IllegalArgumentException if an unknown field value is given.

      Here is the test demonstrating the bug:

      -----------------Test.java------------------------
      import java.util.*;

      public class Test {
          public static void main (String args[]){
              GregorianCalendar calendar = new GregorianCalendar();
              try {
                calendar.roll(-1, true);
                  System.out.println("Test failed, no exception trown");
              } catch (IllegalArgumentException e) {
                  System.out.println("Test passed");
              } catch (Exception e) {
                  System.out.println("Test failed. Unexpected exception is thrown");
                  System.out.println(e);
              }
          }
      }
      ---------Output from the test---------------------
      Test failed. Unexpected exception is thrown
      java.lang.ArrayIndexOutOfBoundsException: -1
      -------------------------------------------------

      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            aliusunw Alan Liu (Inactive)
            Reporter:
            dfazunensunw Dmitri Fazunenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: