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).
|