1.1 --- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Mon Mar 07 13:45:06 2011 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java Mon Mar 07 17:39:42 2011 -0800 1.3 @@ -89,7 +89,7 @@ 1.4 1.5 private FSInfo fsInfo; 1.6 1.7 - private boolean useZipFileIndex; 1.8 + private boolean contextUseOptimizedZip; 1.9 private ZipFileIndexCache zipFileIndexCache; 1.10 1.11 private final File uninited = new File("U N I N I T E D"); 1.12 @@ -164,8 +164,8 @@ 1.13 1.14 fsInfo = FSInfo.instance(context); 1.15 1.16 - useZipFileIndex = options.isSet("useOptimizedZip"); 1.17 - if (useZipFileIndex) 1.18 + contextUseOptimizedZip = options.getBoolean("useOptimizedZip", true); 1.19 + if (contextUseOptimizedZip) 1.20 zipFileIndexCache = ZipFileIndexCache.getSharedInstance(); 1.21 1.22 mmappedIO = options.isSet("mmappedIO"); 1.23 @@ -471,9 +471,27 @@ 1.24 private static final RelativeDirectory symbolFilePrefix 1.25 = new RelativeDirectory("META-INF/sym/rt.jar/"); 1.26 1.27 + /* 1.28 + * This method looks for a ZipFormatException and takes appropriate 1.29 + * evasive action. If there is a failure in the fast mode then we 1.30 + * fail over to the platform zip, and allow it to deal with a potentially 1.31 + * non compliant zip file. 1.32 + */ 1.33 + protected Archive openArchive(File zipFilename) throws IOException { 1.34 + try { 1.35 + return openArchive(zipFilename, contextUseOptimizedZip); 1.36 + } catch (IOException ioe) { 1.37 + if (ioe instanceof ZipFileIndex.ZipFormatException) { 1.38 + return openArchive(zipFilename, false); 1.39 + } else { 1.40 + throw ioe; 1.41 + } 1.42 + } 1.43 + } 1.44 + 1.45 /** Open a new zip file directory, and cache it. 1.46 */ 1.47 - protected Archive openArchive(File zipFileName) throws IOException { 1.48 + private Archive openArchive(File zipFileName, boolean useOptimizedZip) throws IOException { 1.49 File origZipFileName = zipFileName; 1.50 if (!ignoreSymbolFile && paths.isDefaultBootClassPathRtJar(zipFileName)) { 1.51 File file = zipFileName.getParentFile().getParentFile(); // ${java.home} 1.52 @@ -495,7 +513,7 @@ 1.53 boolean usePreindexedCache = false; 1.54 String preindexCacheLocation = null; 1.55 1.56 - if (!useZipFileIndex) { 1.57 + if (!useOptimizedZip) { 1.58 zdir = new ZipFile(zipFileName); 1.59 } else { 1.60 usePreindexedCache = options.isSet("usezipindex"); 1.61 @@ -524,23 +542,22 @@ 1.62 } 1.63 1.64 if (origZipFileName == zipFileName) { 1.65 - if (!useZipFileIndex) { 1.66 + if (!useOptimizedZip) { 1.67 archive = new ZipArchive(this, zdir); 1.68 } else { 1.69 archive = new ZipFileIndexArchive(this, 1.70 - zipFileIndexCache.getZipFileIndex(zipFileName, 1.71 + zipFileIndexCache.getZipFileIndex(zipFileName, 1.72 null, 1.73 usePreindexedCache, 1.74 preindexCacheLocation, 1.75 options.isSet("writezipindexfiles"))); 1.76 } 1.77 } else { 1.78 - if (!useZipFileIndex) { 1.79 + if (!useOptimizedZip) { 1.80 archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix); 1.81 - } 1.82 - else { 1.83 + } else { 1.84 archive = new ZipFileIndexArchive(this, 1.85 - zipFileIndexCache.getZipFileIndex(zipFileName, 1.86 + zipFileIndexCache.getZipFileIndex(zipFileName, 1.87 symbolFilePrefix, 1.88 usePreindexedCache, 1.89 preindexCacheLocation, 1.90 @@ -549,6 +566,8 @@ 1.91 } 1.92 } catch (FileNotFoundException ex) { 1.93 archive = new MissingArchive(zipFileName); 1.94 + } catch (ZipFileIndex.ZipFormatException zfe) { 1.95 + throw zfe; 1.96 } catch (IOException ex) { 1.97 if (zipFileName.exists()) 1.98 log.error("error.reading.file", zipFileName, getMessage(ex));