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

Duration(lexicalRepresentation) throws StringIndexOutOfBoundsException for blank

XMLWordPrintable

    • b36
    • generic
    • generic
    • Verified

      Duration(java.lang.String lexicalRepresentation) throws StringIndexOutOfBoundsException when 'lexicalRepresentation' is a blank string ""

      but according to the spec this case should throw java.lang.IllegalArgumentException

      Test Program - Test1.java
      -----------------------------------------------------------------------------
      import javax.xml.datatype.Duration;

      public class Test1 {
       
          Test1() {}

          // main()
          public static void main(String[] argv) {
              Test1 test1 = new Test1();
              test1.checkDuration01();
          } //end main()
          
          // test for constructor Duration(java.lang.String lexicalRepresentation)
          // lexRepresentation - invalid blank string "" - should throw IllegalArgumentException
          private void checkDuration01() {
             String lexRepresentation = "" ;
             try{
                 Duration duration01 = new Duration(lexRepresentation);
                 System.out.println(" Expected IllegalArgumentException not thrown - checkDuration01() failed ");
             }catch( NullPointerException npe){
                 System.out.println(" NPE thrown - checkDuration01() failed ");
             }catch( IllegalArgumentException iae){
                 System.out.println(" Expected IllegalArgumentException thrown - checkDuration01() passed ");
             }catch( StringIndexOutOfBoundsException sioobe ){
                 System.out.println(" StringIndexOutOfBoundsException thrown - checkDuration01() failed "+sioobe.getMessage());
             }catch( Exception e){
                 System.out.println(" Exception thrown - checkDuration01() failed " );
             }
          }

      }

      -----------------------------------------------------------------------------
      ---------------------------------
      verified in Tiger 1.5.0-beta2-b44
      ###@###.### 2004-03-30
      ---------------------------------

            jfialli Joe Fialli
            saksunw Sreejith Ak (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: