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

Print this page




  49 import java.util.Collections;
  50 import java.util.Enumeration;
  51 import java.util.HashMap;
  52 import java.util.HashSet;
  53 import java.util.LinkedList;
  54 import java.util.List;
  55 import java.util.NoSuchElementException;
  56 import java.util.Set;
  57 import java.util.Stack;
  58 import java.util.StringTokenizer;
  59 import java.util.concurrent.atomic.AtomicInteger;
  60 import java.util.jar.JarFile;
  61 import java.util.zip.ZipEntry;
  62 import java.util.jar.JarEntry;
  63 import java.util.jar.Manifest;
  64 import java.util.jar.Attributes;
  65 import java.util.jar.Attributes.Name;
  66 
  67 import jdk.internal.jimage.ImageLocation;
  68 import jdk.internal.jimage.ImageReader;


  69 
  70 import sun.net.util.URLUtil;
  71 import sun.net.www.ParseUtil;
  72 import sun.net.www.protocol.jrt.JavaRuntimeURLConnection;
  73 
  74 /**
  75  * This class is used to maintain a search path of URLs for loading classes
  76  * and resources from both JAR files and directories.
  77  *
  78  * @author  David Connelly
  79  */
  80 public class URLClassPath {
  81     private static final String USER_AGENT_JAVA_VERSION = "UA-Java-Version";
  82     private static final String JAVA_HOME;
  83     private static final String JAVA_VERSION;
  84     private static final boolean DEBUG;
  85     private static final boolean DISABLE_JAR_CHECKING;
  86 
  87     static {
  88         JAVA_HOME = java.security.AccessController.doPrivileged(


 605 
 606         /*
 607          * Returns the local class path for this loader, or null if none.
 608          */
 609         URL[] getClassPath() throws IOException {
 610             return null;
 611         }
 612     }
 613 
 614     /*
 615      * Inner class used to represent a Loader of resources from a JAR URL.
 616      */
 617     static class JarLoader extends Loader {
 618         private JarFile jar;
 619         private URL csu;
 620         private JarIndex index;
 621         private MetaIndex metaIndex;
 622         private URLStreamHandler handler;
 623         private HashMap<String, Loader> lmap;
 624         private boolean closed = false;
 625         private static final sun.misc.JavaUtilZipFileAccess zipAccess =
 626                 sun.misc.SharedSecrets.getJavaUtilZipFileAccess();
 627 
 628         /*
 629          * Creates a new JarLoader for the specified URL referring to
 630          * a JAR file.
 631          */
 632         JarLoader(URL url, URLStreamHandler jarHandler,
 633                   HashMap<String, Loader> loaderMap)
 634             throws IOException
 635         {
 636             super(new URL("jar", "", -1, url + "!/", jarHandler));
 637             csu = url;
 638             handler = jarHandler;
 639             lmap = loaderMap;
 640 
 641             if (!isOptimizable(url)) {
 642                 ensureOpen();
 643             } else {
 644                  String fileName = url.getFile();
 645                 if (fileName != null) {
 646                     fileName = ParseUtil.decode(fileName);




  49 import java.util.Collections;
  50 import java.util.Enumeration;
  51 import java.util.HashMap;
  52 import java.util.HashSet;
  53 import java.util.LinkedList;
  54 import java.util.List;
  55 import java.util.NoSuchElementException;
  56 import java.util.Set;
  57 import java.util.Stack;
  58 import java.util.StringTokenizer;
  59 import java.util.concurrent.atomic.AtomicInteger;
  60 import java.util.jar.JarFile;
  61 import java.util.zip.ZipEntry;
  62 import java.util.jar.JarEntry;
  63 import java.util.jar.Manifest;
  64 import java.util.jar.Attributes;
  65 import java.util.jar.Attributes.Name;
  66 
  67 import jdk.internal.jimage.ImageLocation;
  68 import jdk.internal.jimage.ImageReader;
  69 import jdk.internal.misc.JavaUtilZipFileAccess;
  70 import jdk.internal.misc.SharedSecrets;
  71 
  72 import sun.net.util.URLUtil;
  73 import sun.net.www.ParseUtil;
  74 import sun.net.www.protocol.jrt.JavaRuntimeURLConnection;
  75 
  76 /**
  77  * This class is used to maintain a search path of URLs for loading classes
  78  * and resources from both JAR files and directories.
  79  *
  80  * @author  David Connelly
  81  */
  82 public class URLClassPath {
  83     private static final String USER_AGENT_JAVA_VERSION = "UA-Java-Version";
  84     private static final String JAVA_HOME;
  85     private static final String JAVA_VERSION;
  86     private static final boolean DEBUG;
  87     private static final boolean DISABLE_JAR_CHECKING;
  88 
  89     static {
  90         JAVA_HOME = java.security.AccessController.doPrivileged(


 607 
 608         /*
 609          * Returns the local class path for this loader, or null if none.
 610          */
 611         URL[] getClassPath() throws IOException {
 612             return null;
 613         }
 614     }
 615 
 616     /*
 617      * Inner class used to represent a Loader of resources from a JAR URL.
 618      */
 619     static class JarLoader extends Loader {
 620         private JarFile jar;
 621         private URL csu;
 622         private JarIndex index;
 623         private MetaIndex metaIndex;
 624         private URLStreamHandler handler;
 625         private HashMap<String, Loader> lmap;
 626         private boolean closed = false;
 627         private static final JavaUtilZipFileAccess zipAccess =
 628                 SharedSecrets.getJavaUtilZipFileAccess();
 629 
 630         /*
 631          * Creates a new JarLoader for the specified URL referring to
 632          * a JAR file.
 633          */
 634         JarLoader(URL url, URLStreamHandler jarHandler,
 635                   HashMap<String, Loader> loaderMap)
 636             throws IOException
 637         {
 638             super(new URL("jar", "", -1, url + "!/", jarHandler));
 639             csu = url;
 640             handler = jarHandler;
 641             lmap = loaderMap;
 642 
 643             if (!isOptimizable(url)) {
 644                 ensureOpen();
 645             } else {
 646                  String fileName = url.getFile();
 647                 if (fileName != null) {
 648                     fileName = ParseUtil.decode(fileName);