20.14
java.lang.ClassLoader
THE PACKAGE JAVA.LANG
20.14 The Class
java.lang.ClassLoader
A class loader is an object that is responsible for loading classes. Given the name
of a class, it should attempt to locate or generate data that constitutes a definition
for the class. A typical strategy is to transform the name into a file name and then
read a class file of that name from a file system.
Every
Class
object contains a reference to the
ClassLoader
that defined it
( 20.3.7). Whenever executable Java code needs to use a class that has not yet
been loaded, the
loadClass
method is invoked for the class loader of the class
containing the code in question.
Class objects for array classes are not created by class loaders, but are created
automatically as required by the Java runtime. The class loader for an array class,
as returned by the
getClassLoader
method of class
Class
( 20.3.7), is the same
as the class loader for its element type; if the element type is a primitive type, then
the array class has no class loader.
Class loaders may typically be used by security managers ( 20.17) to indicate
security domains: two classes may considered to be friendly or related to each
other only if they were defined by the same class loader.
public abstract class ClassLoader {
protected ClassLoader() throws SecurityException;
protected abstract Class loadClass(String name,
boolean resolve)
throws ClassNotFoundException;
protected final Class defineClass(byte data[],
int offset, int length)
throws NullPointerException, IndexOutOfBoundsException,
ClassFormatError;
protected final void resolveClass(Class c)
throws NullPointerException;
protected final Class findSystemClass(String name)
throws ClassNotFoundException;
}
20.14.1
protected ClassLoader() throws SecurityException
This constructor is invoked for every newly created class loader. Because the class
ClassLoader
is
abstract
, it is not possible to create a new instance of the class
ClassLoader
itself; however, every constructor for a subclass of
ClassLoader
necessarily invokes this constructor, explicitly or implicitly, directly or indirectly.
All this constructor does is to enforce a security check: if there is a security
manager, its
checkCreateClassLoader
method ( 20.17.10) is called.
558
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved