Contents | Prev | Next | Index

checkcast

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

Linking Exceptions
During resolution of the CONSTANT_Class constant pool item, any of the exceptions documented in §5.1 can be thrown.

Runtime Exception
Otherwise, if objectref cannot be cast to the resolved class, array, or interface type, the checkcast instruction throws a ClassCast-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

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