United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6873352 : Jar fails silently on Windows-style slashes

Details
Type:
Enhancement
Submit Date:
2009-08-19
Status:
Closed
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2010-08-19
Component:
core-libs
OS:
windows_vista
Sub-Component:
java.util.jar
CPU:
x86
Priority:
P5
Resolution:
Not an Issue
Affected Versions:
6u10
Fixed Versions:

Related Reports

Sub Tasks

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..."
                                     
2010-08-19



Hardware and Software, Engineered to Work Together