EXECUTION
Initialize
Test
: Execute Initializers
12.1.3
a.out
file that contains a fully linked version of the program, including com
pletely resolved links to library routines used by the program. Copies of these
library routines are included in the
a.out
file.)
An implementation may instead choose to resolve a symbolic reference only
when it is actively used; consistent use of this strategy for all symbolic references
would represent the laziest form of resolution. In this case, if
Test
had several
symbolic references to another class, then the references might be resolved one at
a time, as they are used, or perhaps not at all, if these references were never used
during execution of the program.
The only requirement on when resolution is performed is that any errors
detected during resolution must be thrown at a point in the program where some
action is taken by the program that might, directly or indirectly, require linkage to
the class or interface involved in the error. Using the static example implemen
tation choice described above, loading and linkage errors could occur before the
program is executed if they involved a class or interface mentioned in the class
Test
or any of the further, recursively referenced, classes and interfaces. In a
system that implemented the laziest resolution, these errors would be thrown
only when an incorrect symbolic reference is actively used.
The resolution process is described further in 12.3.3.
12.1.3 Initialize
Test
: Execute Initializers
In our continuing example, the virtual machine is still trying to execute the
method
main
of class
Test
. This is an attempted active use ( 12.4.1) of the class,
which is permitted only if the class has been initialized.
Initialization consists of execution of any class variable initializers and static
initializers of the class
Test
, in textual order. But before
Test
can be initialized,
its direct superclass must be initialized, as well as the direct superclass of its direct
superclass, and so on, recursively. In the simplest case,
Test
has
Object
as its
implicit direct superclass; if class
Object
has not yet been initialized, then it must
be initialized before
Test
is initialized. Class
Object
has no superclass, so the
recursion terminates here.
If class
Test
has another class
Super
as its superclass, then
Super
must be
initialized before
Test
. This requires loading, verifying, and preparing
Super
if
this has not already been done and, depending on the implementation, may also
involve resolving the symbolic references from
Super
and so on, recursively.
Initialization may thus cause loading, linking, and initialization errors, includ
ing such errors involving other types.
The initialization process is described further in 12.4.
217
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