JDK-6295519 : javac throws ZipException when you have invalid files in classpath
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0u2,5.0u5
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,other
  • Submitted: 2005-07-11
  • Updated: 2016-03-23
  • Resolved: 2006-03-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6
5.0u7Fixed 6 b78Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
javac throws a ZipException if you have a non-jar/non-zip file in the classpath. For example, the following command on a Linux system throws an exception

$ javac -classpath .:/usr/lib/libm.so Test.java

The documentation says that it should ignore non-jar/non-zip files. See <http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html>. This is a regression from 1.4. 1.4 ignores such files, 1.5 does not. We see similar behaviour on our MacOSX version.

Looking at the code, I found the following code in src/share/classes/com/sun/tools/javac/util/Paths.java

    /** Is this the name of a zip file? */
    private static boolean isZip(String name) {
      return new File(name).isFile();
    }

This looks suspicious. It seems the code just checks to see if the file exists. It does not check to see if it is a valid zip file. bug 4971117 is slightly different but (I think) related to this bug.

Release Regression From : 5.0u2
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.
###@###.### 2005-07-11 21:17:32 GMT

Comments
WORK AROUND Deleted text.
24-11-2005

EVALUATION Contrary to the submitter's statement, this problem also exists in 5.0u2. $ /usr/java/jdk1.5.0/bin/javac -J-showversion -classpath .:/usr/lib/libm.so Test.java java version "1.5.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64) Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode) error: error reading /usr/lib/libm.so; java.util.zip.ZipException: error in opening zip file 1 error $ /usr/java/jdk1.5.0_01/bin/javac -J-showversion -classpath .:/usr/lib/libm.so Test.java java version "1.5.0_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08) Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode) error: error reading /usr/lib/libm.so; java.util.zip.ZipException: error in opening zip file 1 error $ /usr/java/jdk1.5.0_02/bin/javac -J-showversion -classpath .:/usr/lib/libm.so Test.java java version "1.5.0_02" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09) Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode, sharing) error: error reading /usr/lib/libm.so; java.util.zip.ZipException: error in opening zip file 1 error ###@###.### 2005-07-12 02:59:31 GMT
12-07-2005