Interface ChildClassLoader
- All Known Implementing Classes:
ChildURLClassLoader
public interface ChildClassLoader
Defines the interface of a child class loader, mixed from
ClassLoader and
java.net.URLClassLoader.- Author:
- Holger Eichelberger, SSE
-
Method Summary
Modifier and TypeMethodDescriptionvoidSets the default assertion status for this class loader tofalseand discards any package defaults or class assertion status settings associated with the class loader.Class<?> Finds and loads the class with the specified name from the URL search path.getResource(String name) Finds the resource with the given name.getResourceAsStream(String name) Returns an input stream for reading the specified resource.getResources(String name) Finds all the resources with the given name.voidsetClassAssertionStatus(String className, boolean enabled) Sets the desired assertion status for the named top-level class in this class loader and any nested classes contained therein.voidsetDefaultAssertionStatus(boolean enabled) Sets the default assertion status for this class loader.voidsetPackageAssertionStatus(String packageName, boolean enabled) Sets the package default assertion status for the named package.
-
Method Details
-
findClass
Finds and loads the class with the specified name from the URL search path. Any URLs referring to JAR files are loaded and opened as needed until the class is found.- Parameters:
name- the name of the class- Returns:
- the resulting class
- Throws:
ClassNotFoundException- if the class could not be found, or if the loader is closed.NullPointerException- ifnameis null
-
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.- Parameters:
name- The resource name- Returns:
- A
URLobject for reading the resource, or null if the resource could not be found or the invoker doesn't have adequate privileges to get the resource.
-
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.- Parameters:
name- The resource name- Returns:
- An enumeration of
URLobjects for the resource. If no resources could be found, the enumeration will be empty. Resources that the class loader doesn't have access to will not be in the enumeration. - Throws:
IOException- If I/O errors occur
-
getResourceAsStream
Returns an input stream for reading the specified resource.- Parameters:
name- The resource name- Returns:
- An input stream for reading the resource, or null if the resource could not be found
-
setClassAssertionStatus
Sets the desired assertion status for the named top-level class in this class loader and any nested classes contained therein. This setting takes precedence over the class loader's default assertion status, and over any applicable per-package default. This method has no effect if the named class has already been initialized. (Once a class is initialized, its assertion status cannot change.)- Parameters:
className- The fully qualified class name of the top-level class whose assertion status is to be set.enabled-trueif the named class is to have assertions enabled when (and if) it is initialized,falseif the class is to have assertions disabled.
-
clearAssertionStatus
void clearAssertionStatus()Sets the default assertion status for this class loader tofalseand discards any package defaults or class assertion status settings associated with the class loader. This method is provided so that class loaders can be made to ignore any command line or persistent assertion status settings and "start with a clean slate." -
setDefaultAssertionStatus
void setDefaultAssertionStatus(boolean enabled) Sets the default assertion status for this class loader. This setting determines whether classes loaded by this class loader and initialized in the future will have assertions enabled or disabled by default.- Parameters:
enabled-trueif classes loaded by this class loader will henceforth have assertions enabled by default,falseif they will have assertions disabled by default.
-
setPackageAssertionStatus
Sets the package default assertion status for the named package. The package default assertion status determines the assertion status for classes initialized in the future that belong to the named package or any of its "subpackages".- Parameters:
packageName- The name of the package whose package default assertion status is to be set. A null value indicates the unnamed package that is "current"enabled-trueif classes loaded by this classloader and belonging to the named package or any of its subpackages will have assertions enabled by default,falseif they will have assertions disabled by default.
-