src/share/classes/com/sun/tools/javac/file/JavacFileManager.java

changeset 923
6970d9fb8e02
parent 893
8f0dcb9499db
child 1111
d2cbb77469ed
equal deleted inserted replaced
916:cb9493a80341 923:6970d9fb8e02
87 */ 87 */
88 private Paths paths; 88 private Paths paths;
89 89
90 private FSInfo fsInfo; 90 private FSInfo fsInfo;
91 91
92 private boolean useZipFileIndex; 92 private boolean contextUseOptimizedZip;
93 private ZipFileIndexCache zipFileIndexCache; 93 private ZipFileIndexCache zipFileIndexCache;
94 94
95 private final File uninited = new File("U N I N I T E D"); 95 private final File uninited = new File("U N I N I T E D");
96 96
97 private final Set<JavaFileObject.Kind> sourceOrClass = 97 private final Set<JavaFileObject.Kind> sourceOrClass =
162 paths.setContext(context); 162 paths.setContext(context);
163 } 163 }
164 164
165 fsInfo = FSInfo.instance(context); 165 fsInfo = FSInfo.instance(context);
166 166
167 useZipFileIndex = options.isSet("useOptimizedZip"); 167 contextUseOptimizedZip = options.getBoolean("useOptimizedZip", true);
168 if (useZipFileIndex) 168 if (contextUseOptimizedZip)
169 zipFileIndexCache = ZipFileIndexCache.getSharedInstance(); 169 zipFileIndexCache = ZipFileIndexCache.getSharedInstance();
170 170
171 mmappedIO = options.isSet("mmappedIO"); 171 mmappedIO = options.isSet("mmappedIO");
172 ignoreSymbolFile = options.isSet("ignore.symbol.file"); 172 ignoreSymbolFile = options.isSet("ignore.symbol.file");
173 173
469 469
470 private static final String[] symbolFileLocation = { "lib", "ct.sym" }; 470 private static final String[] symbolFileLocation = { "lib", "ct.sym" };
471 private static final RelativeDirectory symbolFilePrefix 471 private static final RelativeDirectory symbolFilePrefix
472 = new RelativeDirectory("META-INF/sym/rt.jar/"); 472 = new RelativeDirectory("META-INF/sym/rt.jar/");
473 473
474 /*
475 * This method looks for a ZipFormatException and takes appropriate
476 * evasive action. If there is a failure in the fast mode then we
477 * fail over to the platform zip, and allow it to deal with a potentially
478 * non compliant zip file.
479 */
480 protected Archive openArchive(File zipFilename) throws IOException {
481 try {
482 return openArchive(zipFilename, contextUseOptimizedZip);
483 } catch (IOException ioe) {
484 if (ioe instanceof ZipFileIndex.ZipFormatException) {
485 return openArchive(zipFilename, false);
486 } else {
487 throw ioe;
488 }
489 }
490 }
491
474 /** Open a new zip file directory, and cache it. 492 /** Open a new zip file directory, and cache it.
475 */ 493 */
476 protected Archive openArchive(File zipFileName) throws IOException { 494 private Archive openArchive(File zipFileName, boolean useOptimizedZip) throws IOException {
477 File origZipFileName = zipFileName; 495 File origZipFileName = zipFileName;
478 if (!ignoreSymbolFile && paths.isDefaultBootClassPathRtJar(zipFileName)) { 496 if (!ignoreSymbolFile && paths.isDefaultBootClassPathRtJar(zipFileName)) {
479 File file = zipFileName.getParentFile().getParentFile(); // ${java.home} 497 File file = zipFileName.getParentFile().getParentFile(); // ${java.home}
480 if (new File(file.getName()).equals(new File("jre"))) 498 if (new File(file.getName()).equals(new File("jre")))
481 file = file.getParentFile(); 499 file = file.getParentFile();
493 ZipFile zdir = null; 511 ZipFile zdir = null;
494 512
495 boolean usePreindexedCache = false; 513 boolean usePreindexedCache = false;
496 String preindexCacheLocation = null; 514 String preindexCacheLocation = null;
497 515
498 if (!useZipFileIndex) { 516 if (!useOptimizedZip) {
499 zdir = new ZipFile(zipFileName); 517 zdir = new ZipFile(zipFileName);
500 } else { 518 } else {
501 usePreindexedCache = options.isSet("usezipindex"); 519 usePreindexedCache = options.isSet("usezipindex");
502 preindexCacheLocation = options.get("java.io.tmpdir"); 520 preindexCacheLocation = options.get("java.io.tmpdir");
503 String optCacheLoc = options.get("cachezipindexdir"); 521 String optCacheLoc = options.get("cachezipindexdir");
522 } 540 }
523 } 541 }
524 } 542 }
525 543
526 if (origZipFileName == zipFileName) { 544 if (origZipFileName == zipFileName) {
527 if (!useZipFileIndex) { 545 if (!useOptimizedZip) {
528 archive = new ZipArchive(this, zdir); 546 archive = new ZipArchive(this, zdir);
529 } else { 547 } else {
530 archive = new ZipFileIndexArchive(this, 548 archive = new ZipFileIndexArchive(this,
531 zipFileIndexCache.getZipFileIndex(zipFileName, 549 zipFileIndexCache.getZipFileIndex(zipFileName,
532 null, 550 null,
533 usePreindexedCache, 551 usePreindexedCache,
534 preindexCacheLocation, 552 preindexCacheLocation,
535 options.isSet("writezipindexfiles"))); 553 options.isSet("writezipindexfiles")));
536 } 554 }
537 } else { 555 } else {
538 if (!useZipFileIndex) { 556 if (!useOptimizedZip) {
539 archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix); 557 archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix);
540 } 558 } else {
541 else {
542 archive = new ZipFileIndexArchive(this, 559 archive = new ZipFileIndexArchive(this,
543 zipFileIndexCache.getZipFileIndex(zipFileName, 560 zipFileIndexCache.getZipFileIndex(zipFileName,
544 symbolFilePrefix, 561 symbolFilePrefix,
545 usePreindexedCache, 562 usePreindexedCache,
546 preindexCacheLocation, 563 preindexCacheLocation,
547 options.isSet("writezipindexfiles"))); 564 options.isSet("writezipindexfiles")));
548 } 565 }
549 } 566 }
550 } catch (FileNotFoundException ex) { 567 } catch (FileNotFoundException ex) {
551 archive = new MissingArchive(zipFileName); 568 archive = new MissingArchive(zipFileName);
569 } catch (ZipFileIndex.ZipFormatException zfe) {
570 throw zfe;
552 } catch (IOException ex) { 571 } catch (IOException ex) {
553 if (zipFileName.exists()) 572 if (zipFileName.exists())
554 log.error("error.reading.file", zipFileName, getMessage(ex)); 573 log.error("error.reading.file", zipFileName, getMessage(ex));
555 archive = new MissingArchive(zipFileName); 574 archive = new MissingArchive(zipFileName);
556 } 575 }

mercurial