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

XMLGregorianCalendar.parse throws StringIndexOutOfBoundsException

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b35
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description



      Name: erR10175 Date: 12/26/2003


       
        The following method of the class javax.xml.datatype.XMLGregorianCalendar

      public static XMLGregorianCalendar parse(String lexicalRepresentation)

      throws StringIndexOutOfBoundsException, that is not a subclass of IllegalArgumentException
      which is the only exception specified in the method description.

      This bug affects new test in JCK 1.5 (not integrated yet)
          api/javax_xml/datatype/XMLGregorianCalendar/index.html#Parse[Parse003]

      The bug is found in jdk1.5.0/beta/b32.

      To reproduce the bug compile and run the following code as shown
      in the log below:
      ------------------------------------------ test.java
      import javax.xml.datatype.XMLGregorianCalendar;

      class test {
          static final String [] parseValuesInvalid = {
             "",
             "1",
             "70",
             "x",
             "xx",
             "xxx",
             "13:20",
             "1.0",
             "Fri Dec 19 15:57:17 NST 2003",
             "2004/01/01",
             "01/01/01",

          };
          public static void main(String [] args) {
              for(int i = 0; i < parseValuesInvalid.length; ++i) {
                  try {
                      XMLGregorianCalendar calendar
                          = XMLGregorianCalendar.parse(parseValuesInvalid[i]);
                      System.out.println("parse('" + parseValuesInvalid[i]
                                  + "') does not throw IllegalArgumentException");
                  } catch (IllegalArgumentException e) {
                  } catch (Exception e) {
                      System.out.println("parse('" + parseValuesInvalid[i]
                          + "') throws " + e + ", expected IllegalArgumentException");
                  }
              }
          }
      }
      ----------------------------------------------------

      ------------------------------------------------ log
      $javac test.java && java -cp . -showversion test
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32, mixed mode)

      parse('') throws java.lang.StringIndexOutOfBoundsException: String index out of range: 2, expected IllegalArgumentException
      parse('1') throws java.lang.StringIndexOutOfBoundsException: String index out of range: 2, expected IllegalArgumentException
      parse('70') throws java.lang.StringIndexOutOfBoundsException: String index out of range: 2, expected IllegalArgumentException
      parse('x') throws java.lang.StringIndexOutOfBoundsException: String index out of range: 2, expected IllegalArgumentException
      parse('xx') throws java.lang.StringIndexOutOfBoundsException: String index out of range: 2, expected IllegalArgumentException
      ----------------------------------------------------

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

        Attachments

          Activity

            People

            Assignee:
            jfialli Joe Fialli
            Reporter:
            reysunw Rey Rey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: