Java Reference
In-Depth Information
For most classes, where visibility of the class is essential across separate
compilations, the name must be consistently formulated at Marker
14
and everywhere the class is referenced. Languages like C
require
that parametric type values be included in the class name, so that the
code generated for Vector
++
<
int
>
can be distinguished from the code for
Vector
<
double
>
.
Inheritance:
aspecificationof
cd
's superclass(es) is emitted at Marker
15
.
Such information is necessary to realize the method calls and instance
variables that are inherited by
cd
.
All Java objects (except Object) extend exactly one Java class. Thus,
inheritance in Java can be specified as a single superclass extended by
cd
and a set of interfaces implemented by
cd
.
For languages like C
er
multiple inheritance
,codemustbe
generated to include information from all of
cd
's superclasses.
++
that o
ff
Instance variables (fields):
for each field declared in the class, information
about the field's name, type, and access permission is generated at
Marker
16
. When combined with information from
cd
's superclasses,
such information allows provisioning of the data area required for each
instance of
cd
.
Static variables:
these are processed at Marker
17
like instance variables, but
they are allocated just once. All instances of
cd
accessthesamestorage
for static variables.
For JVM code generation, the class instantiation information can be described
succinctly, relying on runtime interpretation of the descriptions to initialize
class instances appropriately. Amore thorough treatment of such initialization—
including static and instance variable allocation and virtual method table
construction—is presented in Section 13.1.3 on page 496.
(ClassDeclaring) method initiates translation of
each method defined in class
cd
. By calling for each method
node
to accept
this
visitor, the code at Marker
18
causes the current visitor (TopVisitor)to
process
node
recursively. This action triggers the processing of
node
by the
visit
As its final step, the
visit
(MethodDeclaring) code presented next.