Top Fields Constructors Methods
io.vertx.core.impl

public Class IsolatingClassLoader

extends URLClassLoader
Class Inheritance
Imports
java.io.IOException, java.net.URL, .URLClassLoader, java.util.Collections, .Enumeration, .List

Author
Tim Fox

Field Summary

Modifier and TypeField and Description
private volatile boolean
private List<String>

Constructor Summary

AccessConstructor and Description
public
IsolatingClassLoader(URL[] urls, ClassLoader parent, List<String> isolatedClasses)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.net.URLClassLoader.close.

Implements java.io.Closeable.close.

Closes this URLClassLoader, so that it can no longer be used to load new classes or resources that are defined by this loader.

public URL
getResource(String
The resource name
name
)

Overrides java.lang.ClassLoader.getResource.

Finds the resource with the given name.

public Enumeration<URL>
getResources(String
The resource name
name
)

Overrides java.lang.ClassLoader.getResources.

Finds all the resources with the given name.

public boolean
private boolean
private boolean
protected Class<?>
loadClass(String
The binary name of the class
name
,
boolean
If true then resolve the class
resolve
)

Overrides java.lang.ClassLoader.loadClass.

Loads the class with the specified binary name.

Inherited from java.net.URLClassLoader:
addURLdefinePackagefindClassfindResourcefindResourcesgetPermissionsgetResourceAsStreamgetURLsnewInstancenewInstance

Field Detail

closedback to summary
private volatile boolean closed
isolatedClassesback to summary
private List<String> isolatedClasses

Constructor Detail

IsolatingClassLoaderback to summary
public IsolatingClassLoader(URL[] urls, ClassLoader parent, List<String> isolatedClasses)

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.net.URLClassLoader.close.

Implements java.io.Closeable.close.

Doc from java.net.URLClassLoader.close.

Closes this URLClassLoader, so that it can no longer be used to load new classes or resources that are defined by this loader. Classes and resources defined by any of this loader's parents in the delegation hierarchy are still accessible. Also, any classes or resources that are already loaded, are still accessible.

In the case of jar: and file: URLs, it also closes any files that were opened by it. If another thread is loading a class when the close method is invoked, then the result of that load is undefined.

The method makes a best effort attempt to close all opened files, by catching IOExceptions internally. Unchecked exceptions and errors are not caught. Calling close on an already closed loader has no effect.

Annotations
@Override
Exceptions
IOException:
if closing any file opened by this class loader resulted in an IOException. Any such exceptions are caught internally. If only one is caught, then it is re-thrown. If more than one exception is caught, then the second and following exceptions are added as suppressed exceptions of the first one caught, which is then re-thrown.
getResourceback to summary
public URL getResource(String name)

Overrides java.lang.ClassLoader.getResource.

Doc from java.lang.ClassLoader.getResource.

Finds the resource with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code.

The name of a resource is a '/'-separated path name that identifies the resource.

Resources in named modules are subject to the encapsulation rules specified by Module.getResourceAsStream. Additionally, and except for the special case where the resource has a name ending with ".class", this method will only find resources in packages of named modules when the package is opened unconditionally (even if the caller of this method is in the same module as the resource).

Parameters
name:String

The resource name

Returns:URL

URL object for reading the resource; null if the resource could not be found, a URL could not be constructed to locate the resource, the resource is in a package that is not opened unconditionally, or access to the resource is denied by the security manager.

Annotations
@Override
getResourcesback to summary
public Enumeration<URL> getResources(String name) throws IOException

Overrides java.lang.ClassLoader.getResources.

Doc from java.lang.ClassLoader.getResources.

Finds all the resources with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code.

The name of a resource is a /-separated path name that identifies the resource.

Resources in named modules are subject to the encapsulation rules specified by Module.getResourceAsStream. Additionally, and except for the special case where the resource has a name ending with ".class", this method will only find resources in packages of named modules when the package is opened unconditionally (even if the caller of this method is in the same module as the resource).

Parameters
name:String

The resource name

Returns:Enumeration<URL>

An enumeration of URL objects for the resource. If no resources could be found, the enumeration will be empty. Resources for which a URL cannot be constructed, are in a package that is not opened unconditionally, or access to the resource is denied by the security manager, are not returned in the enumeration.

Annotations
@Override
Exceptions
IOException:
If I/O errors occur
isClosedback to summary
public boolean isClosed()
isIsolatedClassback to summary
private boolean isIsolatedClass(String name)
isVertxOrSystemClassback to summary
private boolean isVertxOrSystemClass(String name)
loadClassback to summary
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException

Overrides java.lang.ClassLoader.loadClass.

Doc from java.lang.ClassLoader.loadClass.

Loads the class with the specified binary name. The default implementation of this method searches for classes in the following order:

  1. Invoke findLoadedClass(String) to check if the class has already been loaded.

  2. Invoke the loadClass method on the parent class loader. If the parent is null the class loader built into the virtual machine is used, instead.

  3. Invoke the findClass(String) method to find the class.

If the class was found using the above steps, and the resolve flag is true, this method will then invoke the resolveClass(Class) method on the resulting Class object.

Subclasses of ClassLoader are encouraged to override findClass(String), rather than this method.

Unless overridden, this method synchronizes on the result of getClassLoadingLock method during the entire class loading process.

Parameters
name:String

The binary name of the class

resolve:boolean

If true then resolve the class

Returns:Class<?>

The resulting Class object

Annotations
@Override
Exceptions
ClassNotFoundException:
If the class could not be found