Returns the system class loader for delegation. This is the default
delegation parent for new
ClassLoader instances, and is
typically the class loader used to start the application.
This method is first invoked early in the runtime's startup
sequence, at which point it creates the system class loader and sets it
as the context class loader of the invoking Thread.
The default system class loader is an implementation-dependent
instance of this class.
If the system property "java.system.class.loader" is defined
when this method is first invoked then the value of that property is
taken to be the name of a class that will be returned as the system
class loader. The class is loaded using the default system class loader
and must define a public constructor that takes a single parameter of
type ClassLoader which is used as the delegation parent. An
instance is then created using this constructor with the default system
class loader as the parameter. The resulting class loader is defined
to be the system class loader.
If a security manager is present, and the invoker's class loader is
not null and the invoker's class loader is not the same as or
an ancestor of the system class loader, then this method invokes the
security manager's checkPermission
method with a RuntimePermission("getClassLoader")
permission to verify
access to the system class loader. If not, a
SecurityException will be thrown.
Returns:
The system
ClassLoader for delegation, or
null if none
Throws:
-
SecurityException - If a security manager exists and its
checkPermission
method doesn't allow access to the system class loader.
-
IllegalStateException - If invoked recursively during the construction of the class
loader specified by the "
java.system.class.loader"
property.
-
Error - If the system property "
java.system.class.loader"
is defined but the named class could not be loaded, the
provider class does not define the required constructor, or an
exception is thrown by that constructor when it is invoked. The
underlying cause of the error can be retrieved via the
{@link Throwable#getCause()} method.