United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7036255 javac crashes when a specific system option is set
JDK-7036255 : javac crashes when a specific system option is set

Details
Type:
Bug
Submit Date:
2011-04-13
Status:
Resolved
Updated Date:
2011-05-02
Project Name:
JDK
Resolved Date:
2011-04-14
Component:
tools
OS:
linux
Sub-Component:
javac
CPU:
x86
Priority:
P1
Resolution:
Fixed
Affected Versions:
6u25
Fixed Versions:
6u25 (b06)

Related Reports
Relates:
Relates:

Sub Tasks

Description
When compiling using the useJavaUtilZip=true system option (that disables caching of the zip file indices in memory), the 6u25 javac crashes:
$ ./jdk1.6.0_25/bin/javac -J-DuseJavaUtilZip=true Test.java
error: error reading /tmp/jdk1.6.0_25/jre/lib/sunrsasign.jar; error in opening zip file
1 error

The javac version is:
$ ./jdk1.6.0_25/bin/javac -fullversion
javac full version "1.6.0_25-b05"

NetBeans is using this system option to prevent leaking memory through the zip file index cache: when a project is built inside NetBeans, the javac is run in the same VM to speed-up the building of small projects.

                                    

Comments
SUGGESTED FIX

The fix is the same as shown in 6625520:
            } catch (IOException ex) {
>>>>>>>>>>>	if (zipFileName.exists())
                	log.error("error.reading.file", zipFileName, ex.getLocalizedMessage());
                archive = new MissingArchive(zipFileName);
            }
                                     
2011-04-13
EVALUATION

As Jon pointed out in the comment, the problem is the openArchive method in DefaultFileManager.java.  It does this:
            try {
                 :
                if (!useZipFileIndex) {
                    zdir = new ZipFile(zipFileName);
                }
                 :
            } catch (FileNotFoundException ex) {
                archive = new MissingArchive(zipFileName);
            } catch (IOException ex) {
                log.error("error.reading.file", zipFileName, ex.getLocalizedMessage());
                archive = new MissingArchive(zipFileName);
            }

The problem is that new ZipFile(...) doesn't throw a FileNotFoundException if the file does not exist, instead, it throws a java.util.zip.ZipException, so that the log.error is executed.
                                     
2011-04-13
EVALUATION

This problem exists on Linux and Solaris. On Windows new ZipFile(...) does throw a FileNotFoundException.
                                     
2011-04-14



Hardware and Software, Engineered to Work Together