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

JAR tool in JDK1.2 causes FileNotFoundException by removing any beginning '/'

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.2.0
    • 1.2.0
    • tools
    • None
    • jar
    • 1.2beta4
    • x86
    • solaris_2.5.1
    • Verified

      Assuming /files/testdir is an existing directory with a few files in it, type at the commandline on Solaris using the JDK1.2Beta3...

      jar cf0 classes.jar /files/testdir

      You should see the following exception...

      java.io.FileNotFoundException: files/testdir/<name of a file in the directory>
              at java.io.FileInputStream.<init>(FileInputStream.java:58)
              at sun.tools.jar.Manifest.doHashes(Manifest.java:175)
              at sun.tools.jar.Manifest.addFile(Manifest.java:159)
              at sun.tools.jar.Manifest.addFiles(Manifest.java:131)
              at sun.tools.jar.Manifest.addFiles(Manifest.java:129)
              at sun.tools.jar.Main.create(Main.java:255)
              at sun.tools.jar.Main.run(Main.java:97)
              at sun.tools.jar.Main.main(Main.java:524)

      This behavior is only seen when not specifying the M flag. When you don't specify the M flag, a sequence of methods get called, one of which is localToStd(String name) located in sun.tools.jar.Manifest.java. This method appeared as follows in 1.1.6...

      private final String localToStd(String name) {
      return name.replace(java.io.File.separatorChar, '/');
          }


      but in 1.2 appears as...

      private final String localToStd(String name) {
      name = name.replace(java.io.File.separatorChar, '/');
      if (name.startsWith("./"))
      name = name.substring(2);
      else if (name.startsWith("/"))
      name = name.substring(1);
      return name;
          }


      The fact that I pass a path beginning with a '/' causes this method to remove it which results in an invalid path and thus, a filenotfound exception. My current application relies on the beginning forward slash not being removed.


            dconnellsunw David Connelly (Inactive)
            kgrucci Kyle Grucci
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: