< prev index next >

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

Print this page

        

*** 32,45 **** import java.util.stream.Stream; import java.util.stream.StreamSupport; import java.util.zip.*; import java.security.CodeSigner; import java.security.cert.Certificate; - import java.security.AccessController; import java.security.CodeSource; - import sun.misc.IOUtils; - import sun.security.action.GetPropertyAction; import sun.security.util.ManifestEntryVerifier; import sun.misc.SharedSecrets; import sun.security.util.SignatureFileVerifier; /** --- 32,42 ----
*** 83,92 **** --- 80,92 ---- // Set up JavaUtilJarAccess in SharedSecrets static { SharedSecrets.setJavaUtilJarAccess(new JavaUtilJarAccessImpl()); } + private static final sun.misc.JavaUtilZipFileAccess zipAccess + = sun.misc.SharedSecrets.getJavaUtilZipFileAccess(); + /** * The JAR manifest file name. */ public static final String MANIFEST_NAME = "META-INF/MANIFEST.MF";
*** 183,205 **** private Manifest getManifestFromReference() throws IOException { Manifest man = manRef != null ? manRef.get() : null; if (man == null) { ! JarEntry manEntry = getManEntry(); // If found then load the manifest ! if (manEntry != null) { ! if (verify) { ! byte[] b = getBytes(manEntry); man = new Manifest(new ByteArrayInputStream(b)); ! if (!jvInitialized) { jv = new JarVerifier(b); } - } else { - man = new Manifest(super.getInputStream(manEntry)); - } manRef = new SoftReference<>(man); } } return man; } --- 183,201 ---- private Manifest getManifestFromReference() throws IOException { Manifest man = manRef != null ? manRef.get() : null; if (man == null) { ! JarEntry entry = getManEntry(); // If found then load the manifest ! if (entry != null) { ! byte[] b = zipAccess.getBytes(this, entry); man = new Manifest(new ByteArrayInputStream(b)); ! if (verify && !jvInitialized) { jv = new JarVerifier(b); } manRef = new SoftReference<>(man); } } return man; }
*** 374,384 **** } if (mev == null) { mev = new ManifestEntryVerifier (getManifestFromReference()); } ! byte[] b = getBytes(e); if (b != null && b.length > 0) { jv.beginEntry(e, mev); jv.update(b.length, b, 0, b.length, mev); jv.update(-1, null, 0, 0, mev); } --- 370,380 ---- } if (mev == null) { mev = new ManifestEntryVerifier (getManifestFromReference()); } ! byte[] b = zipAccess.getBytes(this, e); if (b != null && b.length > 0) { jv.beginEntry(e, mev); jv.update(b.length, b, 0, b.length, mev); jv.update(-1, null, 0, 0, mev); }
*** 414,433 **** verify = false; } } } - /* - * Reads all the bytes for a given entry. Used to process the - * META-INF files. - */ - private byte[] getBytes(ZipEntry ze) throws IOException { - try (InputStream is = super.getInputStream(ze)) { - return IOUtils.readFully(is, (int)ze.getSize(), true); - } - } - /** * Returns an input stream for reading the contents of the specified * zip file entry. * @param ze the zip file entry * @return an input stream for reading the contents of the specified --- 410,419 ----
*** 546,558 **** * On first invocation, check if the JAR file has the Class-Path * attribute. A no-op on subsequent calls. */ private void checkForSpecialAttributes() throws IOException { if (hasCheckedSpecialAttributes) return; ! JarEntry manEntry = getManEntry(); ! if (manEntry != null) { ! byte[] b = getBytes(manEntry); if (match(CLASSPATH_CHARS, b, CLASSPATH_LASTOCC, CLASSPATH_OPTOSFT)) hasClassPathAttribute = true; } hasCheckedSpecialAttributes = true; } --- 532,544 ---- * On first invocation, check if the JAR file has the Class-Path * attribute. A no-op on subsequent calls. */ private void checkForSpecialAttributes() throws IOException { if (hasCheckedSpecialAttributes) return; ! JarEntry entry = getManEntry(); ! if (entry != null) { ! byte[] b = zipAccess.getBytes(this, entry); if (match(CLASSPATH_CHARS, b, CLASSPATH_LASTOCC, CLASSPATH_OPTOSFT)) hasClassPathAttribute = true; } hasCheckedSpecialAttributes = true; }
< prev index next >