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

Javadoc incorrectly states about Jar URL

XMLWordPrintable

    • beta2
    • sparc
    • solaris_2.6



      Name: dfR10049 Date: 08/28/2000



      Javadoc states about java.net.JarURLConnection:

          When constructing a JAR url via new URL(context, spec), the following rules apply:

          if there is no context URL and the specification passed to the URL constructor
          doesn't contain a separator, the URL is considered to refer to a JarFile.

          if there is a context URL, the context URL is assumed to refer to a JAR file or
          a Jar directory.

          if the specification begins with a '/', the Jar directory is ignored, and the spec
          is considered to be at the root of the Jar file.

          Examples:

          context: jar:http://www.foo.com/bar/jar.jar!/, spec:baz/entry.txt
              url:jar:http://www.foo.com/bar/baz/jar.jar!/baz/entry.txt

          context: jar:http://www.foo.com/bar/jar.jar!/baz, spec:entry.txt
              url:jar:http://www.foo.com/bar/baz/jar.jar!/baz/entry.txt

          context: jar:http://www.foo.com/bar/jar.jar!/baz, spec:/entry.txt
              url:jar:http://www.foo.com/bar/baz/jar.jar!/entry.txt


      But examples are not working:

      1) misprint:
            context: jar:http://www.foo.com/bar/jar.jar!/baz, spec:/entry.txt
                                            ^^^^^^^^^^^^
                 url:jar:http://www.foo.com/bar/baz/jar.jar!/entry.txt
                                            ^^^^^^^^^^^^^^^^
          path to jar.jar should be not changed

      2) second example after correction:

          context: jar:http://www.foo.com/bar/jar.jar!/baz, spec:entry.txt
              url: jar:http://www.foo.com/bar/jar.jar!/baz/entry.txt

        but new URL(new URL("jar:http://www.foo.com/bar/jar.jar!/baz"), "entry.txt")
        will create url "jar:http://www.foo.com/bar/jar.jar!/entry.txt"
                    not "jar:http://www.foo.com/bar/jar.jar!/baz/entry.txt"

      Imho, second example should be replaced with:

          context: jar:http://www.foo.com/bar/jar.jar!/baz/, spec:entry.txt
              url: jar:http://www.foo.com/bar/jar.jar!/baz/entry.txt

          context: jar:http://www.foo.com/bar/jar.jar!/baz, spec:entry.txt
              url: jar:http://www.foo.com/bar/jar.jar!/entry.txt

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

            jhosunw Jamie Ho (Inactive)
            fdasunw Fda Fda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: