United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6295519 javac throws ZipException when you have invalid files in classpath
JDK-6295519 : javac throws ZipException when you have invalid files in classpath

Details
Type:
Bug
Submit Date:
2005-07-11
Status:
Resolved
Updated Date:
2010-04-03
Project Name:
JDK
Resolved Date:
2006-03-23
Component:
tools
OS:
generic,windows_xp
Sub-Component:
javac
CPU:
other,generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
5.0u2,5.0u5
Fixed Versions:

Related Reports
Backport:
Duplicate:
Relates:
Relates:

Sub Tasks

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
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
                                     
2005-07-12
WORK AROUND

Deleted text.
                                     
2005-11-24



Hardware and Software, Engineered to Work Together