< prev index next >

src/java.base/share/classes/sun/misc/JarIndex.java

Print this page

        

*** 23,36 **** * questions. */ package sun.misc; ! import java.io.*; ! import java.util.*; ! import java.util.jar.*; ! import java.util.zip.*; /** * This class is used to maintain mappings from packages, classes * and resources to their enclosing JAR files. Mappings are kept * at the package level except for class or resource files that --- 23,52 ---- * questions. */ package sun.misc; ! 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 * and resources to their enclosing JAR files. Mappings are kept * at the package level except for class or resource files that
*** 72,81 **** --- 88,100 ---- * be added to the index. Otherwise, just the directory names are added. */ 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. */ public JarIndex() { indexMap = new HashMap<>();
*** 132,143 **** --- 151,171 ---- return null; } JarEntry e = jar.getJarEntry(INDEX_NAME); // if found, then load the index if (e != null) { + 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; } /** * Returns the jar files that are defined in this index.
< prev index next >