--- old/src/java.base/share/classes/java/util/jar/JarFile.java 2015-05-22 11:32:38.079612786 -0700 +++ new/src/java.base/share/classes/java/util/jar/JarFile.java 2015-05-22 11:32:37.951612790 -0700 @@ -34,10 +34,7 @@ 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; @@ -85,6 +82,9 @@ SharedSecrets.setJavaUtilJarAccess(new JavaUtilJarAccessImpl()); } + private static final sun.misc.JavaUtilZipFileAccess zipAccess + = sun.misc.SharedSecrets.getJavaUtilZipFileAccess(); + /** * The JAR manifest file name. */ @@ -185,18 +185,14 @@ if (man == null) { - JarEntry manEntry = getManEntry(); + JarEntry entry = 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)); + 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); } @@ -376,7 +372,7 @@ mev = new ManifestEntryVerifier (getManifestFromReference()); } - byte[] b = getBytes(e); + 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); @@ -416,16 +412,6 @@ } } - /* - * 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. @@ -548,9 +534,9 @@ */ private void checkForSpecialAttributes() throws IOException { if (hasCheckedSpecialAttributes) return; - JarEntry manEntry = getManEntry(); - if (manEntry != null) { - byte[] b = getBytes(manEntry); + JarEntry entry = getManEntry(); + if (entry != null) { + byte[] b = zipAccess.getBytes(this, entry); if (match(CLASSPATH_CHARS, b, CLASSPATH_LASTOCC, CLASSPATH_OPTOSFT)) hasClassPathAttribute = true; }