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

URL(context, spec) constructor generates StringOutOfBoundsException for Jar file

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.3.0
    • core-libs
    • beta
    • x86
    • linux



      Name: skT45625 Date: 12/18/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
      Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)


      Get a MalformedURLException that says that a StringIndexOutOfBounds exception
      were thrown when trying to add a directory or file entry in a jar URL.

      Example code:

      import java.net.*;

      class UrlExample {

          public static void main( String[] args ) {
      try {
      URL context = new URL( "jar:http://balloo.com/olle.jar!/" );
      String spec = "p2";

                  URL p2Url = new URL( context, spec );

      System.out.println( "p2Url = " + p2Url.toString() );
      } catch( Exception e ) {
      e.printStackTrace( System.err );
      }
          }
      }

      Executing a this class gives the following:
      java.net.MalformedURLException: java.lang.StringIndexOutOfBoundsException:
      String index out of range: 4
              at java.net.URL.<init>(URL.java:496)
              at java.net.URL.<init>(URL.java:376)
              at UrlExample.main(UrlExample.java:11)
      (Review ID: 113969)
      ======================================================================

            michaelm Michael McMahon
            skondamasunw Suresh Kondamareddy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: