Java Reference
In-Depth Information
cannot be subverted by code written in the Java programming language, not even by
implementations of such otherwise sensitive system classes as ClassLoader and Secur-
ityManager .
12.2.1. The Loading Process
The loading process is implemented by the class ClassLoader and its subclasses.
Different subclasses of ClassLoader may implement different loading policies. In particular,
a class loader may cache binary representations of classes and interfaces, prefetch them
based on expected usage, or load a group of related classes together. These activities may
not be completely transparent to a running application if, for example, a newly compiled
version of a class is not found because an older version is cached by a class loader. It is
the responsibility of a class loader, however, to reflect loading errors only at points in the
program where they could have arisen without prefetching or group loading.
If an error occurs during class loading, then an instance of one of the following subclasses
of class LinkageError will be thrown at any point in the program that (directly or indirectly)
uses the type:
ClassCircularityError : A class or interface could not be loaded because it would be its
own superclass or superinterface (§ 8.1.4 , § 9.1.3 , § 13.4.4 ) .
ClassFormatError : The binary data that purports to specify a requested compiled class
or interface is malformed.
NoClassDefFoundError : No definition for a requested class or interface could be found
by the relevant class loader.
Because loading involves the allocation of new data structures, it may fail with an
OutOfMemoryError .
12.3. Linking of Classes and Interfaces
Linking is the process of taking a binary form of a class or interface type and combining it
into the run-time state of the Java Virtual Machine, so that it can be executed. A class or
interface type is always loaded before it is linked.
Three different activities are involved in linking: verification, preparation, and resolution
of symbolic references.
The precise semantics of linking are given in Chapter 5 of The Java Virtual Machine Spe-
cification, Java SE 7 Edition . Here we present an overview of the process from the view-
point of the Java programming language.
Search WWH ::




Custom Search