EXECUTION
Loading: Implications for Code Generation
12.2.2
the Java language is that the type system cannot be subverted by code written in
Java, not even by implementations of such otherwise sensitive system classes as
ClassLoader
( 20.14) and
SecurityManager
( 20.17).
An entry may be deleted from the internal table only after unloading ( 12.8)
the class or interface represented by the class object in the entry.
12.2.1 The Loading Process
The loading process is implemented by the class
ClassLoader
( 20.14) and its
subclasses. Different subclasses of
ClassLoader
may implement different load
ing 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 Java 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 responsi
bility of a class loader, however, to reflect loading errors only at points in the pro
gram they could have arisen without prefetching or group loading.
If an error occurs during class loading, then an instance of one of the follow
ing subclasses of class
LinkageError
will be thrown at any point in the Java pro
gram 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 ( 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.2.2 Loading: Implications for Code Generation
A cooperating class loader can enable a code generator to generate code for a
group of class and interface types perhaps an entire package by loading the
binary code for these types as a group. A format can be designed that allows all
the internal symbolic references in such a group to be resolved, before the group is
loaded. Such a strategy may also allow the generated code to be optimized before
loading based on the known concrete types in the group. This approach may be
useful in specific cases, but is discouraged as a general technique, since such a
class file format is unlikely to be widely understood.
219
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