📄 instructions2.doc19.html
字号:
<html><head><title>VM Spec </title></head><body BGCOLOR=#eeeeff text=#000000 LINK=#0000ff VLINK=#000077 ALINK=#ff0000> <a href="VMSpecTOC.doc.html">Contents</a> | <a href="Instructions2.doc18.html">Prev</a> | <a href="Instructions2.doc20.html">Next</a> | <a href="Mnemonics.doc.html">Index</a><hr><br> <a name="checkcast"></a><h2>checkcast</h2><a name="checkcast.Operation"></a><b>Operation</b><br><a name="67380"></a>Check whether object is of given type<p><Table Border="3"><tr><td><a name="67375"></a> <i>checkcast</i><td><a name="87568"></a> <tr><td><a name="67377"></a> <i>indexbyte1</i><td><a name="87568"></a> <tr><td><a name="67379"></a> <i>indexbyte2</i><td><a name="87568"></a> </Table><Table><tr><td></Table><p><a name="checkcast.Forms"></a><b>Forms</b><br><a name="67381"></a><i>checkcast</i> = 192 (0xc0)<p><a name="checkcast.Stack"></a><b>Stack</b><br><a name="67382"></a>..., <i>objectref</i><em> </em><img src="chars/arrwdbrt.gif"> ..., <i>objectref</i><p><a name="checkcast.Description"></a><b>Description</b><br><a name="153291"></a>The <i>objectref</i> must be of type <code>reference</code>. The unsigned <i>indexbyte1</i> and <i>indexbyte2</i> are used to construct an index into the constant pool of the current class <a href="Overview.doc.html#17257">(§3.6)</a>, where the value of the index is (<i>indexbyte1</i> << 8) | <i>indexbyte2</i>. The constant pool item at the index must be a <code>CONSTANT_Class</code> <a href="ClassFile.doc.html#1221">(§4.4.1)</a>, a symbolic reference to a class, array, or interface type. The symbolic reference is resolved <a href="ConstantPool.doc.html#51579">(§5.1)</a>.<p><a name="140250"></a>If <i>objectref</i> is <code>null</code> or can be cast to the resolved class, array, or interface type, the operand stack is unchanged; otherwise, the <i>checkcast</i> instruction throws a <code>ClassCastException</code>.<p><a name="140259"></a>The following rules are used to determine whether an <i>objectref</i> that is not <code>null</code> can be cast to the resolved type: if S is the class of the object referred to by <i>objectref</i> and T is the resolved class, array, or interface type, <i>checkcast</i> determines whether <i>objectref</i> can be cast to type T as follows:<p><hr><!-- This inserts footnotes--><p><a href="VMSpecTOC.doc.html">Contents</a> | <a href="Instructions2.doc18.html">Prev</a> | <a href="Instructions2.doc20.html">Next</a> | <a href="Mnemonics.doc.html">Index</a><p><font size=-1>Java Virtual Machine Specification (HTML generated by dkramer on February 25, 1997)<br><i><a href="Copyright.doc.html">Copyright © 1996 Sun Microsystems, Inc.</a>All rights reserved</i><br>Please send any comments or corrections to <a href="mailto:doug.kramer@sun.com">doug.kramer@sun.com</a></font></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -