< prev index next >

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

Print this page

        

*** 26,35 **** --- 26,36 ---- package java.util.jar; import java.io.*; import java.lang.ref.SoftReference; import java.net.URL; + import java.nio.ByteBuffer; import java.util.*; import java.util.stream.Stream; import java.util.stream.StreamSupport; import java.util.zip.*; import java.security.CodeSigner;
*** 83,92 **** --- 84,96 ---- // 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";
*** 187,205 **** 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; } --- 191,205 ---- JarEntry manEntry = getManEntry(); // If found then load the manifest if (manEntry != null) { byte[] b = getBytes(manEntry); man = new Manifest(new ByteArrayInputStream(b)); ! if (verify && !jvInitialized) { jv = new JarVerifier(b); } manRef = new SoftReference<>(man); } } return man; }
*** 419,430 **** /* * 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 --- 419,435 ---- /* * Reads all the bytes for a given entry. Used to process the * META-INF files. */ private byte[] getBytes(ZipEntry ze) throws IOException { ! ByteBuffer bb = zipAccess.getByteBuffer(this, ze); ! if (bb.hasArray()) { ! return bb.array(); ! } else { ! byte[] bytes = new byte[bb.remaining()]; ! bb.get(bytes); ! return bytes; } } /** * Returns an input stream for reading the contents of the specified
< prev index next >