United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6625520 javac handles missing entries on classpath badly
JDK-6625520 : javac handles missing entries on classpath badly

Details
Type:
Bug
Submit Date:
2007-11-02
Status:
Closed
Updated Date:
2012-01-13
Project Name:
JDK
Resolved Date:
2012-01-13
Component:
tools
OS:
generic
Sub-Component:
javac
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:
Relates:

Sub Tasks

Description
In DefaultFileManager, getFileForInput assumes that if a path entry is not a directory, it must be an archive. This applies even if it does not exist.

Separately, openArchive assumes FileNotFoundException will be thrown if the archive is missing.   This may be true on some systems, but is not required to be true. For example, on Ubuntu linux, you get java.io.IOException if a file is not found.  This causes a spurious diagnostic to be generated.

                                    

Comments
SUGGESTED FIX

In openArchive check if file exists before outputting message about trouble reading it:


            try {
                ZipFile zdir = new ZipFile(zipFileName);
                if (origZipFileName == zipFileName)
                    archive = new ZipArchive(zdir);
                else
                    archive = new SymbolArchive(origZipFileName, zdir);
            } catch (FileNotFoundException ex) {
                archive = new MissingArchive(zipFileName);
            } catch (IOException ex) {
>>>>>>>>>>>	if (zipFileName.exists())
                	log.error("error.reading.file", zipFileName, ex.getLocalizedMessage());
                archive = new MissingArchive(zipFileName);
            }


This would make the handling of "IOException/file doesn't exist" the same as the handling of FileNotFoundException.
                                     
2007-11-02
EVALUATION

The bug has been partially masked by the changes to use zip file archives, which protect openArchive from being called if the file does not exist. However, there is still exposure in the JSR199 API method getFileForInput.

However, even then, the bug is hard to reproduce because Ubuntu Linux now seems to give FileNotFoundException, as expected.

Nevertheless the suggested fix is deemed worthy, in case there are other platforms on which the problem may arise.
                                     
2008-06-17



Hardware and Software, Engineered to Work Together