Next: Bytecode Verification and Security Up: The Java Virtual Machine Previous: The JVM Class File   Contents

Code Segments in the JVM

The code segments in the class file use the JVM instruction set. This instruction set includes commands typically found in most stack-based assemblers. Such commands including floating point, integer, and pointer operations, as well as common control instructions. However, the key difference between the JVM and a typical assembler is that additional instructions, specific to object oriented interfaces, are included. Figure 1.1 lists a few such instructions.

Figure 1.1: Object Oriented JVM Instructions
Instruction Purpose
invokevirtual Call a virtual method
invokespecial Call a class or object initializer method
invokestatic Call a static method
newCreate new object instances from a class
putfield Set a field in an object

To pass arguments to method calls, an operand stack is used. Items are pushed onto the operand stack before a method is invoked. Upon completion, the return value of the method is left on the operand stack. The JVM verifier, discussed in the next section, prohibits using the operand stack for any other purpose.

Copyright © 2000, 2001 Bradley M. Kuhn.

Verbatim copying and distribution of this entire thesis is permitted in any medium, provided this notice is preserved.