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

jar --validate may lead to java.nio.file.FileAlreadyExistsException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 25
    • 17
    • tools
    • None
    • jar
    • b03

      When the "jar --validate" command is run as follows:

      cat $JAVA_HOME/lib/jrt-fs.jar | jar --validate

      then it leads to the following exception:

      java.nio.file.FileAlreadyExistsException: /tmp/tmpJar128144111130442323.jar
      at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:94)
      at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
      at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
      at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:262)
      at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:482)
      at java.base/java.nio.file.Files.newOutputStream(Files.java:228)
      at java.base/java.nio.file.Files.copy(Files.java:3164)
      at jdk.jartool/sun.tools.jar.Main.run(Main.java:430)
      at jdk.jartool/sun.tools.jar.Main.main(Main.java:1708)

      This is due to an oversight in the implementation of the validate option, where "Files.copy(in, file.toPath())" is called on an already existing (just generated temporary) target file.

            jpai Jaikiran Pai
            jpai Jaikiran Pai
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: