src/java.base/share/classes/java/util/jar/JarFile.java

Print this page




 531         while (i<=last) {
 532             for (int j=(len-1); j>=0; j--) {
 533                 char c = (char) b[i+j];
 534                 c = (((c-'A')|('Z'-c)) >= 0) ? (char)(c + 32) : c;
 535                 if (c != src[j]) {
 536                     i += Math.max(j + 1 - lastOcc[c&0x7F], optoSft[j]);
 537                     continue next;
 538                  }
 539             }
 540             return true;
 541         }
 542         return false;
 543     }
 544 
 545     /**
 546      * On first invocation, check if the JAR file has the Class-Path
 547      * attribute. A no-op on subsequent calls.
 548      */
 549     private void checkForSpecialAttributes() throws IOException {
 550         if (hasCheckedSpecialAttributes) return;
 551         if (!isKnownNotToHaveSpecialAttributes()) {
 552             JarEntry manEntry = getManEntry();
 553             if (manEntry != null) {
 554                 byte[] b = getBytes(manEntry);
 555                 if (match(CLASSPATH_CHARS, b, CLASSPATH_LASTOCC, CLASSPATH_OPTOSFT))
 556                     hasClassPathAttribute = true;
 557             }
 558         }
 559         hasCheckedSpecialAttributes = true;
 560     }
 561 
 562     private static String javaHome;
 563     private static volatile String[] jarNames;
 564     private boolean isKnownNotToHaveSpecialAttributes() {
 565         // Optimize away even scanning of manifest for jar files we
 566         // deliver which don't have a class-path attribute. If one of
 567         // these jars is changed to include such an attribute this code
 568         // must be changed.
 569         if (javaHome == null) {
 570             javaHome = AccessController.doPrivileged(
 571                 new GetPropertyAction("java.home"));
 572         }
 573         if (jarNames == null) {
 574             String[] names = new String[11];
 575             String fileSep = File.separator;
 576             int i = 0;
 577             names[i++] = fileSep + "rt.jar";
 578             names[i++] = fileSep + "jsse.jar";
 579             names[i++] = fileSep + "jce.jar";
 580             names[i++] = fileSep + "charsets.jar";
 581             names[i++] = fileSep + "dnsns.jar";
 582             names[i++] = fileSep + "zipfs.jar";
 583             names[i++] = fileSep + "localedata.jar";
 584             names[i++] = fileSep = "cldrdata.jar";
 585             names[i++] = fileSep + "sunjce_provider.jar";
 586             names[i++] = fileSep + "sunpkcs11.jar";
 587             names[i++] = fileSep + "sunec.jar";
 588             jarNames = names;
 589         }
 590 
 591         String name = getName();
 592         if (name.startsWith(javaHome)) {
 593             String[] names = jarNames;
 594             for (String jarName : names) {
 595                 if (name.endsWith(jarName)) {
 596                     return true;
 597                 }
 598             }
 599         }
 600         return false;
 601     }
 602 
 603     private synchronized void ensureInitialization() {
 604         try {
 605             maybeInstantiateVerifier();
 606         } catch (IOException e) {
 607             throw new RuntimeException(e);
 608         }
 609         if (jv != null && !jvInitialized) {
 610             initializeVerifier();
 611             jvInitialized = true;
 612         }
 613     }
 614 
 615     JarEntry newEntry(ZipEntry ze) {
 616         return new JarFileEntry(ze);
 617     }
 618 
 619     Enumeration<String> entryNames(CodeSource[] cs) {
 620         ensureInitialization();
 621         if (jv != null) {
 622             return jv.entryNames(this, cs);




 531         while (i<=last) {
 532             for (int j=(len-1); j>=0; j--) {
 533                 char c = (char) b[i+j];
 534                 c = (((c-'A')|('Z'-c)) >= 0) ? (char)(c + 32) : c;
 535                 if (c != src[j]) {
 536                     i += Math.max(j + 1 - lastOcc[c&0x7F], optoSft[j]);
 537                     continue next;
 538                  }
 539             }
 540             return true;
 541         }
 542         return false;
 543     }
 544 
 545     /**
 546      * On first invocation, check if the JAR file has the Class-Path
 547      * attribute. A no-op on subsequent calls.
 548      */
 549     private void checkForSpecialAttributes() throws IOException {
 550         if (hasCheckedSpecialAttributes) return;

 551         JarEntry manEntry = getManEntry();
 552         if (manEntry != null) {
 553             byte[] b = getBytes(manEntry);
 554             if (match(CLASSPATH_CHARS, b, CLASSPATH_LASTOCC, CLASSPATH_OPTOSFT))
 555                 hasClassPathAttribute = true;
 556         }

 557         hasCheckedSpecialAttributes = true;
 558     }
 559 









































 560     private synchronized void ensureInitialization() {
 561         try {
 562             maybeInstantiateVerifier();
 563         } catch (IOException e) {
 564             throw new RuntimeException(e);
 565         }
 566         if (jv != null && !jvInitialized) {
 567             initializeVerifier();
 568             jvInitialized = true;
 569         }
 570     }
 571 
 572     JarEntry newEntry(ZipEntry ze) {
 573         return new JarFileEntry(ze);
 574     }
 575 
 576     Enumeration<String> entryNames(CodeSource[] cs) {
 577         ensureInitialization();
 578         if (jv != null) {
 579             return jv.entryNames(this, cs);