All Packages Class Hierarchy This Package Previous Next Index
Class java.net.URLClassLoader
java.lang.Object
|
+----java.lang.ClassLoader
|
+----java.security.SecureClassLoader
|
+----java.net.URLClassLoader
- public class URLClassLoader
- extends SecureClassLoader
This class loader is used to load classes and resources from a search
path of URLs. Any URLs not ending with a '/' are assumed to refer to
JAR files. The URLs are opened and expanded as needed.
URLClassLoader(URL[])
- Constructs a new URLClassLoader for the specified URLs.
URLClassLoader(URL[], ClassLoader)
-
checkPackageDefinition(String)
- This method can be overridden to throw a
SecurityException
if the calling thread is not allowed to define classes in the package
specified by the argument.
definePackage(String, Attributes, URL)
- Defines a package by name in this ClassLoader.
findLocalClass(String)
- Finds and loads the class with the specified name from the URL
search path.
getExtClassLoader()
- Returns the shared instance of ClassLoader used to load classes
and resources from installed extensions.
getLocalResource(String)
- Finds the resource with the specified name on the URL search path.
getLocalResources(String)
- Returns an Enumeration of URLs representing all of the resources
with the given name that could be found on the URL search path.
invokeClass(String, String[])
- Invokes an application given the name of the application's main
class and an array of arguments.
URLClassLoader
public URLClassLoader(URL[] urls)
- Constructs a new URLClassLoader for the specified URLs. The URLs
will be searched in the order specified after looking for classes
and resources in installed extensions.
- Parameters:
- urls - the URLs from which to load classes and resources
URLClassLoader
public URLClassLoader(URL[] urls,
ClassLoader parent)
findLocalClass
protected Class findLocalClass(String name)
- Finds and loads the class with the specified name from the URL
search path. The base URLs are opened and expanded as needed
until the class is found.
- Parameters:
- name - the name of the class
- Returns:
- the resulting class, or null if not found
- Throws:
SecurityException
- if a package sealing violation has occurred
- Overrides:
- findLocalClass in class ClassLoader
definePackage
protected Package definePackage(String name,
Attributes attr,
URL sealBase)
- Defines a package by name in this ClassLoader. The specification
and implementation titles, names, and vendors are obtained from the
given Attributes object.
- Parameters:
- name - the package name
- attr - the package Attributes
- sealBase - if specified then this package is sealed with respect
to the given code base URL
- Throws:
IllegalArgumentException
- if the package name duplicates an
existing package either in this class loader or the parent
class loader
checkPackageDefinition
protected void checkPackageDefinition(String name) throws SecurityException
- This method can be overridden to throw a
SecurityException
if the calling thread is not allowed to define classes in the package
specified by the argument. By default, the calling thread is allowed
to define classes in any package.
- Parameters:
- name - the package name
- Throws:
SecurityException
- if the caller cannot define classes in
the specified package
getLocalResource
public URL getLocalResource(String name)
- Finds the resource with the specified name on the URL search path.
Returns a URL for the resource, or null if the resource could not
be found.
- Parameters:
- name - the name of the resource
- Overrides:
- getLocalResource in class ClassLoader
getLocalResources
public Enumeration getLocalResources(String name) throws IOException
- Returns an Enumeration of URLs representing all of the resources
with the given name that could be found on the URL search path.
XXX: Why does this need to throw IOException?
- Parameters:
- name - the resource name
- Returns:
- an Enumeration of resource URLs
- Overrides:
- getLocalResources in class ClassLoader
invokeClass
public void invokeClass(String name,
String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException
- Invokes an application given the name of the application's main
class and an array of arguments. The class must define define a
static method "main" which takes an array of String arguments and
is of return type "void".
- Parameters:
- name - the name of the application's main class
- args - the arguments to pass to the application
- Throws:
ClassNotFoundException
- if the specified class could not
be found
- Throws:
NoSuchMethodException
- if the specified class does not
define a "main" method
- Throws:
InvocationTargetException
- if the application raised an
exception
getExtClassLoader
public static ClassLoader getExtClassLoader()
- Returns the shared instance of ClassLoader used to load classes
and resources from installed extensions. By default, new instances
of URLClassLoader will delegate to this class loader.
XXX Use a Reference object here
All Packages Class Hierarchy This Package Previous Next Index
Submit a bug or feature