The most visible change to the virtual machine is the addition of two
new opcodes (named invokewhere
and invokestaticwhere
) that support
invocation of the methods that correspond to the where clauses. They
provide invocation of normal and static methods, respectively. Constructors
are treated as normal methods.
For example, the expression b.key.equals(k)
in Figure 4 is
implemented using invokewhere
, as shown in Figure 6.
aload_2 // push "b" on stack
getfield <Field HashBucket[Key,Value].key #0;>
aload_3 // push "k" on stack
Other minor changes were made to the format of a ".class" file, which
supply the bytecode verifier with enough added information to
directly verify parameterized code. We extended
the encoding of type signatures to capture instantiation and formal
parameter types, and added
information to describe the parameters and where clauses of the class.
Figure 6 shows one example of the extended type signatures:
the signature for equals
includes a ``#0'', which represents the first
formal parameter type (Key
) of the current class. (The Z
indicates that
the return type of equals
is boolean
.)