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

Javadoc incorrectly states about Jar URL

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta2
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      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

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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: