Contents Prev Next Up


The Virtual Machine Instruction Set


Miscellaneous Object Operations

new
newfromname
checkcast
instanceof
verifystack

new

Create new object

... => ..., handle

indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class. The item at that index should be a class name that can be resolved to a class pointer, class. A new instance of that class is then created and a handle for it is pushed on the stack.

newfromname

Create new object

from name

..., handle => ..., new-handle

handle should be a handle to a character array. The class whose name is the string represented by the character array is determined. A new object of that class is created, and a handle new-handle for that object replaces the character array handle on the top of the stack.

If the handle is null, a NullPointerException is thrown. If no such class can be found, a NoClassDefFoundException is thrown.

checkcast

Make sure object is of given type

..., handle => ..., [handle|...]

indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class. The string at that index of the constant pool is presumed to be a class name which can be resolved to a class pointer, class. handle should be a handle to an object.

checkcast determines whether handle can be cast to an object of class class. A null handle can be cast to any class. Otherwise handle must be an instance of class or one of its superclasses. If handle can be cast to class execution proceeds at the next instruction, and the handle for handle remains on the stack.

If handle cannot be cast to class, a ClassCastException is thrown.

instanceof



Determine if object is of given type

..., handle => ..., result

indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class. The string at that index of the constant pool is presumed to be a class name which can be resolved to a class pointer, class. handle should be a handle to an object.

instanceof determines whether handle can be cast to an object of the class class. This instruction will overwrite handle with 1 if handle is null or if it is an instance of class or one of its superclasses. Otherwise, handle is overwritten by 0.

verifystack



Verify stack empty

... => [empty stack]

This instruction is only generated if the code was compiled using a debugging version of the compiler. This instruction indicates that the compiler expects the operand stack to be empty at this point.

If the stack is not currently empty, it will be set to empty. In addition, if running a debugging version of the interpreter, an error message is printed out warning that something is seriously wrong.


Contents Prev Next Up

Generated with CERN WebMaker