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

Print this page




 988      * and the Multi-Release attribute. A no-op on subsequent calls.
 989      */
 990     private void checkForSpecialAttributes() throws IOException {
 991         if (hasCheckedSpecialAttributes) {
 992             return;
 993         }
 994         synchronized (this) {
 995             if (hasCheckedSpecialAttributes) {
 996                 return;
 997             }
 998             JarEntry manEntry = getManEntry();
 999             if (manEntry != null) {
1000                 byte[] b = getBytes(manEntry);
1001                 hasClassPathAttribute = match(CLASSPATH_CHARS, b,
1002                         CLASSPATH_LASTOCC, CLASSPATH_OPTOSFT) != -1;
1003                 // is this a multi-release jar file
1004                 if (MULTI_RELEASE_ENABLED) {
1005                     int i = match(MULTIRELEASE_CHARS, b, MULTIRELEASE_LASTOCC,
1006                             MULTIRELEASE_OPTOSFT);
1007                     if (i != -1) {
1008                         i += MULTIRELEASE_CHARS.length;
1009                         if (i < b.length) {
1010                             byte c = b[i++];
1011                             // Check that the value is followed by a newline
1012                             // and does not have a continuation
1013                             if (c == '\n' &&
1014                                     (i == b.length || b[i] != ' ')) {
1015                                 isMultiRelease = true;
1016                             } else if (c == '\r') {
1017                                 if (i == b.length) {
1018                                     isMultiRelease = true;
1019                                 } else {
1020                                     c = b[i++];
1021                                     if (c == '\n') {
1022                                         if (i == b.length || b[i] != ' ') {
1023                                             isMultiRelease = true;
1024                                         }
1025                                     } else if (c != ' ') {
1026                                         isMultiRelease = true;
1027                                     }
1028                                 }
1029                             }
1030                         }
1031                     }
1032                 }
1033             }
1034             hasCheckedSpecialAttributes = true;
1035         }
1036     }
1037 
1038     private synchronized void ensureInitialization() {
1039         try {
1040             maybeInstantiateVerifier();
1041         } catch (IOException e) {
1042             throw new RuntimeException(e);
1043         }
1044         if (jv != null && !jvInitialized) {
1045             initializeVerifier();
1046             jvInitialized = true;
1047         }
1048     }
1049 
1050     /*




 988      * and the Multi-Release attribute. A no-op on subsequent calls.
 989      */
 990     private void checkForSpecialAttributes() throws IOException {
 991         if (hasCheckedSpecialAttributes) {
 992             return;
 993         }
 994         synchronized (this) {
 995             if (hasCheckedSpecialAttributes) {
 996                 return;
 997             }
 998             JarEntry manEntry = getManEntry();
 999             if (manEntry != null) {
1000                 byte[] b = getBytes(manEntry);
1001                 hasClassPathAttribute = match(CLASSPATH_CHARS, b,
1002                         CLASSPATH_LASTOCC, CLASSPATH_OPTOSFT) != -1;
1003                 // is this a multi-release jar file
1004                 if (MULTI_RELEASE_ENABLED) {
1005                     int i = match(MULTIRELEASE_CHARS, b, MULTIRELEASE_LASTOCC,
1006                             MULTIRELEASE_OPTOSFT);
1007                     if (i != -1) {
1008                         // Read the main attributes of the manifest
1009                         byte[] lbuf = new byte[512];
1010                         Attributes attr = new Attributes();
1011                         attr.read(new Manifest.FastInputStream(
1012                             new ByteArrayInputStream(b)), lbuf);
1013                         isMultiRelease = Boolean.parseBoolean(
1014                             attr.getValue(Attributes.Name.MULTI_RELEASE));
















1015                     }
1016                 }
1017             }
1018             hasCheckedSpecialAttributes = true;
1019         }
1020     }
1021 
1022     private synchronized void ensureInitialization() {
1023         try {
1024             maybeInstantiateVerifier();
1025         } catch (IOException e) {
1026             throw new RuntimeException(e);
1027         }
1028         if (jv != null && !jvInitialized) {
1029             initializeVerifier();
1030             jvInitialized = true;
1031         }
1032     }
1033 
1034     /*