12.3
Linking of Classes and Interfaces
EXECUTION
12.3 Linking of Classes and Interfaces
Linking
is the process of taking a binary form of a class or interface type and com
bining it into the runtime state of the Java Virtual Machine, so that it can be exe
cuted. A class or interface type is always loaded before it is linked. Three different
activities are involved in linking: verification, preparation, and resolution of sym
bolic references.
Java allows an implementation flexibility as to when linking activities (and,
because of recursion, loading) take place, provided that the semantics of the lan
guage are respected, that a class or interface is completely verified and prepared
before it is initialized, and that errors detected during linkage are thrown at a point
in the program where some action is taken by the program that might require link
age to the class or interface involved in the error.
For example, an implementation may choose to resolve each symbolic refer
ence in a class or interface individually, only when it is used (lazy or late resolu
tion), or to resolve them all at once while the class is being verified (static
resolution). This means that the resolution process may continue, in some imple
mentations, after a class or interface has been initialized.
Because linking involves the allocation of new data structures, it may fail with
an
OutOfMemoryError
.
12.3.1 Verification of the Binary Representation
Verification
ensures that the binary representation of a class or interface is struc
turally correct. For example, it checks that every instruction has a valid operation
code; that every branch instruction branches to the start of some other instruction,
rather than into the middle of an instruction; that every method is provided with a
structurally correct signature; and that every instruction obeys the type discipline
of the Java language.
For a more detailed description of the verification process, see the separate
volume of this series,
The Java Virtual Machine Specification
.
If an error occurs during verification, then an instance of the following sub
class of class
LinkageError
will be thrown at the point in the Java program that
caused the class to be verified:
VerifyError
: The binary definition for a class or interface failed to pass a set
of required checks to verify that it obeys the semantics of the Java language
and that it cannot violate the integrity of the Java Virtual Machine. (See
13.4.2, 13.4.4, 13.4.8, and 13.4.16 for some examples.)
220
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