Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6295519

javac throws ZipException when you have invalid files in classpath

XMLWordPrintable

    • 5.0
    • b78
    • generic, other
    • generic, windows_xp

        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

              jjg Jonathan Gibbons
              ksoshals Kirill Soshalskiy (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: