Save This Page
Home » apache-harmony-6.0-src-r917296-snapshot » java » net » [javadoc | source]
java.net
public class: URLClassLoader [javadoc | source]
java.lang.Object
   java.lang.ClassLoader
      java.security.SecureClassLoader
         java.net.URLClassLoader

Direct Known Subclasses:
    SystemClassLoader, SubURLClassLoader

This class loader is responsible for loading classes and resources from a list of URLs which can refer to either directories or JAR files. Classes loaded by this {@code URLClassLoader} are granted permission to access the URLs contained in the URL search list.
Nested Class Summary:
static class  URLClassLoader.SubURLClassLoader   
static class  URLClassLoader.IndexFile   
class  URLClassLoader.URLHandler   
class  URLClassLoader.URLJarHandler   
class  URLClassLoader.URLFileHandler   
Field Summary
 ArrayList<URL> originalUrls     
 List<URL> searchList     
 ArrayList<URLHandler> handlerList     
 Map<URL, URLHandler> handlerMap     
Fields inherited from java.lang.ClassLoader:
classAssertionStatus,  classSigners,  defaultAssertionStatus,  clearAssertionStatus,  packageAssertionStatus
Constructor:
 public URLClassLoader(URL[] urls) 
    Constructs a new {@code URLClassLoader} instance. The newly created instance will have the system ClassLoader as its parent. URLs that end with "/" are assumed to be directories, otherwise they are assumed to be JAR files.
    Parameters:
    urls - the list of URLs where a specific class or file could be found.
    Throws:
    SecurityException - if a security manager exists and its {@code checkCreateClassLoader()} method doesn't allow creation of new ClassLoaders.
 public URLClassLoader(URL[] urls,
    ClassLoader parent) 
    Constructs a new URLClassLoader instance. The newly created instance will have the system ClassLoader as its parent. URLs that end with "/" are assumed to be directories, otherwise they are assumed to be JAR files.
    Parameters:
    urls - the list of URLs where a specific class or file could be found.
    parent - the class loader to assign as this loader's parent.
    Throws:
    SecurityException - if a security manager exists and its {@code checkCreateClassLoader()} method doesn't allow creation of new class loaders.
 public URLClassLoader(URL[] searchUrls,
    ClassLoader parent,
    URLStreamHandlerFactory factory) 
    Constructs a new {@code URLClassLoader} instance. The newly created instance will have the specified {@code ClassLoader} as its parent and use the specified factory to create stream handlers. URLs that end with "/" are assumed to be directories, otherwise they are assumed to be JAR files.
    Parameters:
    searchUrls - the list of URLs where a specific class or file could be found.
    parent - the {@code ClassLoader} to assign as this loader's parent.
    factory - the factory that will be used to create protocol-specific stream handlers.
    Throws:
    SecurityException - if a security manager exists and its {@code checkCreateClassLoader()} method doesn't allow creation of new {@code ClassLoader}s.
Method from java.net.URLClassLoader Summary:
addURL,   definePackage,   findClass,   findClassImpl,   findResource,   findResourceImpl,   findResources,   findResourcesImpl,   getHandler,   getPermissions,   getURLs,   newInstance,   newInstance
Methods from java.security.SecureClassLoader:
defineClass,   defineClass,   getPermissions
Methods from java.lang.ClassLoader:
clearAssertionStatus,   defineClass,   defineClass,   defineClass,   defineClass,   definePackage,   findClass,   findLibrary,   findLoadedClass,   findResource,   findResources,   findSystemClass,   getPackage,   getPackages,   getParent,   getResource,   getResourceAsStream,   getResources,   getStackClassLoader,   getSystemClassLoader,   getSystemResource,   getSystemResourceAsStream,   getSystemResources,   isSameOrAncestor,   isSystemClassLoader,   loadClass,   loadClass,   loadLibrary,   loadLibraryWithClassLoader,   registerInitiatedClass,   resolveClass,   setClassAssertionStatus,   setDefaultAssertionStatus,   setPackageAssertionStatus,   setSigners
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.net.URLClassLoader Detail:
 protected  void addURL(URL url) 
    Adds the specified URL to the search list.
 protected Package definePackage(String packageName,
    Manifest manifest,
    URL url) throws IllegalArgumentException 
    Defines a new package using the information extracted from the specified manifest.
 protected Class<?> findClass(String clsName) throws ClassNotFoundException 
    Tries to locate and load the specified class using the known URLs. If the class could be found, a class object representing the loaded class will be returned.
 Class<?> findClassImpl(String className) 
 public URL findResource(String name) 
    Returns an URL referencing the specified resource or {@code null} if the resource could not be found.
 URL findResourceImpl(String resName) 
    Returns a URL among the given ones referencing the specified resource or null if no resource could be found.
 public Enumeration<URL> findResources(String name) throws IOException 
    Returns all known URLs which point to the specified resource.
  void findResourcesImpl(String name,
    ArrayList<URL> result) 
 URLHandler getHandler(int num) 
 protected PermissionCollection getPermissions(CodeSource codesource) 
    Gets all permissions for the specified {@code codesource}. First, this method retrieves the permissions from the system policy. If the protocol is "file:/" then a new permission, {@code FilePermission}, granting the read permission to the file is added to the permission collection. Otherwise, connecting to and accepting connections from the URL is granted.
 public URL[] getURLs() 
    Returns the search list of this {@code URLClassLoader}.
 public static URLClassLoader newInstance(URL[] urls) 
    Returns a new {@code URLClassLoader} instance for the given URLs and the system {@code ClassLoader} as its parent. The method {@code loadClass()} of the new instance will call {@code SecurityManager.checkPackageAccess()} before loading a class.
 public static URLClassLoader newInstance(URL[] urls,
    ClassLoader parentCl) 
    Returns a new {@code URLClassLoader} instance for the given URLs and the specified {@code ClassLoader} as its parent. The method {@code loadClass()} of the new instance will call the SecurityManager's {@code checkPackageAccess()} before loading a class.