JDK-6873352 : Jar fails silently on Windows-style slashes
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 6u10
  • Priority: P5
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_vista
  • CPU: x86
  • Submitted: 2009-08-19
  • Updated: 2011-02-16
  • Resolved: 2010-08-19
Description
A DESCRIPTION OF THE REQUEST :
java.util.jar.JarOutputStream and the JRE itself seem to have two undocumented quirks:

1) JarEntry representing a directory must end with a slash or else the entry will be interpreted as a directory.

2) All paths passed into JarEntry must use Unix-style slashes '/' to separate paths, or else Java will throw ClassNotFoundException when trying to load class files from the resulting JAR file.

#1 doesn't seem to be Java-specific. Most tools that handle ZIP seem to expect this convention. We should document this explicitly in JarEntry to avoid confusion.

#2 seems to be Java specific. Other tools handle paths using either type of file separator. Either the JRE should be fixed to accept Windows-style slashes or JarEntry should throw an exception when Windows-style slashes are passed in. In either case, failing silently is a recipe for disaster.

JUSTIFICATION :
It is extremely difficult to debug bugs revolving around file separators. Developers will undoubtedly run into this in the future and waste countless hours (as I did).

Comments
EVALUATION (1)ZipEntry.isDirectory() clearly specifies what a "directory" zip/jar entry (2)Zip format specificatin also clearly specifies "All slashes should be forward slashes '/' as opposed to backwards slashes '\' for compatibility..."
19-08-2010