Contents | Prev | Next | IndexThe JavaTM Virtual Machine Specification


checkcast_quick

Operation
Check whether object is of given type

checkcast_quick
indexbyte1
indexbyte2

Forms
checkcast_quick = 224 (0xe0)

Stack
..., objectref ..., objectref

Description
The objectref must be of type reference. The unsigned indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The object at that index of the constant pool must already have been successfully resolved and must be a class or interface type.

If objectref is null or can be cast to the resolved class, array, or interface type, the operand stack is unchanged; otherwise, the checkcast_quick instruction throws a ClassCastException.

The following rules are used to determine whether an objectref that is not null can be cast to the resolved type: If S is the class of the object referred to by objectref and T is the resolved class, array, or interface type, checkcast_quick determines whether objectref can be cast to type T as follows:

S cannot be an interface type, because there are no instances of interfaces, only instances of classes and arrays.

Runtime Exception
If objectref cannot be cast to the type of the resolved class, the checkcast_quick instruction throws a ClassCastException.

Notes
The opcode of this instruction was originally checkcast. The operands of the checkcast instruction are not modified.

The checkcast_quick instruction is very similar to the instanceof_quick instruction. It differs in its treatment of null, its behavior when its test fails (checkcast_quick throws an exception, instanceof_quick pushes a result code), and its effect on the operand stack.



Contents | Prev | Next | Index

Java Virtual Machine Specification (HTML generated by chsieh on March 13, 1997)
Copyright © 1996, 1997 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com