Java Reference
In-Depth Information
This specification allows an implementation flexibility as to when linking activities (and,
because of recursion, loading) take place, provided that the semantics of the Java program-
ming language 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 linkage to the class
or interface involved in the error.
For example, an implementation may choose to resolve each symbolic reference in a class
or interface individually, only when it is used (lazy or late resolution), 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 implementations, after a class or interface has been initial-
ized.
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 structurally cor-
rect. 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 signa-
ture; and that every instruction obeys the type discipline of the Java Virtual Machine lan-
guage.
If an error occurs during verification, then an instance of the following subclass of class
LinkageError will be thrown at the point in the program that caused the class to be verified:
VerifyError : The binary definition for a class or interface failed to pass a set of re-
quired checks to verify that it obeys the semantics of the Java Virtual Machine lan-
guage and that it cannot violate the integrity of the Java Virtual Machine. (See
§ 13.4.2 , § 13.4.4 , § 13.4.9 , and § 13.4.17 for some examples.)
12.3.2. Preparation of a Class or Interface Type
Preparation involves creating the static fields (class variables and constants) for a class or
interface and initializing such fields to the default values (§ 4.12.5 ). This does not require
the execution of any source code; explicit initializers for static fields are executed as part
of initialization (§ 12.4 ), not preparation.
Implementations of the Java Virtual Machine may precompute additional data struc-
tures at preparation time in order to make later operations on a class or interface more
Search WWH ::




Custom Search