public class URLClassLoader extends SecureClassLoader
URLClassLoader are granted permission to access the
URLs contained in the URL search list.proxyCache| Constructor and Description |
|---|
URLClassLoader(URL[] urls)
Constructs a new
URLClassLoader instance. |
URLClassLoader(URL[] urls,
ClassLoader parent)
Constructs a new URLClassLoader instance.
|
URLClassLoader(URL[] searchUrls,
ClassLoader parent,
URLStreamHandlerFactory factory)
Constructs a new
URLClassLoader instance. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addURL(URL url)
Adds the specified URL to the search list.
|
protected Package |
definePackage(String packageName,
Manifest manifest,
URL url)
Defines a new package using the information extracted from the specified
manifest.
|
protected Class<?> |
findClass(String className)
Tries to locate and load the specified class using the known URLs.
|
URL |
findResource(String name)
Returns an URL referencing the specified resource or
null if the
resource could not be found. |
Enumeration<URL> |
findResources(String name)
Returns all known URLs which point to the specified resource.
|
protected PermissionCollection |
getPermissions(CodeSource codesource)
Gets all permissions for the specified
codesource. |
URL[] |
getURLs()
Returns the search list of this
URLClassLoader. |
static URLClassLoader |
newInstance(URL[] urls)
Returns a new
URLClassLoader instance for the given URLs and the
system ClassLoader as its parent. |
static URLClassLoader |
newInstance(URL[] urls,
ClassLoader parentCl)
Returns a new
URLClassLoader instance for the given URLs and the
specified ClassLoader as its parent. |
defineClass, defineClassclearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSignerspublic URLClassLoader(URL[] urls)
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.urls - the list of URLs where a specific class or file could be
found.public URLClassLoader(URL[] urls, ClassLoader parent)
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.public URLClassLoader(URL[] searchUrls, ClassLoader parent, URLStreamHandlerFactory factory)
URLClassLoader instance. The newly created
instance will have the specified 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.searchUrls - the list of URLs where a specific class or file could be
found.parent - the ClassLoader to assign as this loader's parent.factory - the factory that will be used to create protocol-specific
stream handlers.protected void addURL(URL url)
url - the URL which is to add.public Enumeration<URL> findResources(String name) throws IOException
findResources in class ClassLoadername - the name of the requested resource.IOException - if an I/O error occurs while attempting to connect.protected PermissionCollection getPermissions(CodeSource codesource)
codesource. First, this
method retrieves the permissions from the system policy. If the protocol
is "file:/" then a new permission, 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.getPermissions in class SecureClassLoadercodesource - the code source object whose permissions have to be known.public URL[] getURLs()
URLClassLoader.public static URLClassLoader newInstance(URL[] urls)
URLClassLoader instance for the given URLs and the
system ClassLoader as its parent.urls - the list of URLs that is passed to the new URLClassLoader.URLClassLoader instance.public static URLClassLoader newInstance(URL[] urls, ClassLoader parentCl)
URLClassLoader instance for the given URLs and the
specified ClassLoader as its parent.urls - the list of URLs that is passed to the new URLClassLoader.parentCl - the parent class loader that is passed to the new
URLClassLoader.URLClassLoader instance.protected Class<?> findClass(String className) throws ClassNotFoundException
findClass in class ClassLoaderclassName - the name of the class to look for.Class object that is found.ClassNotFoundException - if the specified class cannot be loaded.public URL findResource(String name)
null if the
resource could not be found.findResource in class ClassLoadername - the name of the requested resource.protected Package definePackage(String packageName, Manifest manifest, URL url) throws IllegalArgumentException
packageName - the name of the new package.manifest - the manifest containing additional information for the new
package.url - the URL to the code source for the new package.IllegalArgumentException - if a package with the given name already exists.