--- old/src/java.base/share/classes/sun/misc/JarIndex.java 2015-05-18 18:36:20.279765435 -0700 +++ new/src/java.base/share/classes/sun/misc/JarIndex.java 2015-05-18 18:36:20.151765440 -0700 @@ -25,10 +25,26 @@ package sun.misc; -import java.io.*; -import java.util.*; -import java.util.jar.*; -import java.util.zip.*; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.nio.ByteBuffer; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Map; +import java.util.Vector; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; /** * This class is used to maintain mappings from packages, classes @@ -74,6 +90,9 @@ private static final boolean metaInfFilenames = "true".equals(System.getProperty("sun.misc.JarIndex.metaInfFilenames")); + private static final sun.misc.JavaUtilZipFileAccess zipAccess + = sun.misc.SharedSecrets.getJavaUtilZipFileAccess(); + /** * Constructs a new, empty jar index. */ @@ -134,7 +153,16 @@ JarEntry e = jar.getJarEntry(INDEX_NAME); // if found, then load the index if (e != null) { - index = new JarIndex(jar.getInputStream(e)); + long size = e.getSize(); + if (size > 0 && size < 512 * 1024) { + byte[] bytes = new byte[(int) size]; + ByteBuffer bb = ByteBuffer.wrap(bytes); + zipAccess.fillByteBuffer(jar, e, bb); + index = new JarIndex(new ByteArrayInputStream(bytes, 0, bb.position())); + } else { + // Unknown or too large ZipEntry size to use a array + index = new JarIndex(jar.getInputStream(e)); + } } return index; }