Contents | Prev | Next | Index | The JavaTM Virtual Machine Specification |
Operation
Loadchar
from array
Format
caload
Forms
caload = 52 (0x34)
Operand Stack
..., arrayref, index ..., value
Description
The arrayref must be of typereference
and must refer to an array whose components are of typechar
. The index must be of typeint
. Both arrayref and index are popped from the operand stack. The component of the array at index is retrieved and zero-extended to anint
value. That value is pushed onto the operand stack.
Runtime Exceptions
If arrayref isnull
, caload throws aNullPointerException
.
Otherwise, if index is not within the bounds of the array referenced by arrayref, the caload instruction throws an ArrayIndexOutOfBoundsException
.
Operation
Store intochar
array
Format
castore
Forms
castore = 85 (0x55)
Operand Stack
..., arrayref, index, value ...
Description
The arrayref must be of typereference
and must refer to an array whose components are of typechar
. The index and the value must both be of typeint
. The arrayref, index, and value are popped from the operand stack. Theint
value is truncated to achar
and stored as the component of the array indexed by index.
Runtime Exceptions
If arrayref isnull
, castore throws aNullPointerException
.
Otherwise, if index is not within the bounds of the array referenced by arrayref, the castore instruction throws an ArrayIndexOutOfBoundsException
.
Operation
Check whether object is of given type
Format
checkcast indexbyte1 indexbyte2
Forms
checkcast = 192 (0xc0)
Operand Stack
..., objectref ..., objectref
Description
The objectref must be of type reference
. The unsigned indexbyte1 and indexbyte2 are used to construct an index into the runtime constant pool of the current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The runtime constant pool item at the index must be a symbolic reference to a class, array, or interface type. The named class, array, or interface type is resolved (§5.4.3.1).
If objectref isnull
or can be cast to the resolved class, array, or interface type, the operand stack is unchanged; otherwise, the checkcast instruction throws aClassCastException
.
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 determines whether objectref can be cast to type T as follows:
[]
, that is, an array of components of type SC, then:
Linking Exceptions
During resolution of the symbolic reference to the class, array, or interface type, any of the exceptions documented in Section 5.4.3.1 can be thrown.
Runtime Exception
Otherwise, if objectref cannot be cast to the resolved class, array, or interface type, the checkcast instruction throws aClassCast
Exception
.
Notes
The checkcast instruction is very similar to the instanceof instruction. It differs in its treatment of null
, its behavior when its test fails (checkcast throws an exception, instanceof pushes a result code), and its effect on the operand stack.
Contents | Prev | Next | Index
The JavaTM Virtual Machine Specification
Copyright © 1999 Sun Microsystems, Inc.
All rights reserved
Please send any comments or corrections to jvm@java.sun.com