Java Reference
In-Depth Information
Type
JVM designation
boolean
Z
byte
B
double
D
float
F
int
I
long
J
short
S
void
V
Reference type t
L t ;
Array of type a
[ a
Figure 10.4: Java types and their designation in the JVM. All of the
integer-valued types are signed. For reference types, t is a
fully qualified class name. For array types, a canbea
primitive, reference, or array type.
As shown in Figure 10.4, the JVM can construct an array of a given type
(primitive or reference). While the result of the construction is a form of
a reference type, it is formally designated using the array character [.For
aesthetic purposes, it might be nice if the opening bracket of the designation
were balanced by a closing bracket, but such is not the case. Remember that
the JVM and Jasmin syntax are rarely read or written directly by humans. The
syntax is therefore designed to be terse rather than familiar.
Constant Pool
Java programs refer to various runtime constants, and these are usually allo-
cated in a class's constant pool . The constant pool is designed as a tagged
union as discussed in Chapter 8. Each entry represents a constant of a given
type, such as int, float,orjava.lang.String, and each can take as much
room as it needs in the constant pool. An int might take only four bytes, but
a String's allocated space will depend on its length.
A constant is referenced by its ordinal position (0, 1, 2, etc.) in the constant
pool, and not by a byte-o
set into the pool (see Exercises 2 and 3). For some
instructions (e.g., ldc), a constant-pool reference occupies a single byte. Other
instructions (e.g., ldc w) provision two bytes for a constant-pool reference.
ff
 
Search WWH ::




Custom Search