⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quick2.doc1.html

📁 Jvm 规范说明。The Java Virtual Machine was designed to support the Java programming language. Some concep
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>VM Spec  </title>
</head>
<body BGCOLOR=#eeeeff text=#000000 LINK=#0000ff VLINK=#000077 ALINK=#ff0000>
<table width=600><tr>
<td><a href="Copyright.doc.html">Contents</a> | <a href="Quick2.doc.html">Prev</a> | <a href="Quick2.doc2.html">Next</a> | <a href="Lindholm.INDEX.html">Index</a></td><td align=right><i><i>The Java<sup><font size=-2>TM</font></sup> Virtual Machine Specification</i></i></td>
</tr></table>


<hr><br>
 

<a name="checkcast_quick"></a>
<h2>checkcast_quick</h2>
<a name="checkcast_quick.Operation"></a>
<b>Operation</b><br>
<a name="5287"></a>
Check whether object is of given type<p>
<Table Border="0">
<tr><td><a name="5282"></a>
 <i>checkcast_quick</i>
<td><a name="397"></a>
 

<tr><td><a name="5284"></a>
 <i>indexbyte1</i>
<td><a name="404"></a>
 

<tr><td><a name="5286"></a>
 <i>indexbyte2</i>
<td><a name="411"></a>
 

</Table>
<p>
<a name="checkcast_quick.Forms"></a>
<b>Forms</b><br>
<a name="5288"></a>
<i>checkcast_quick</i> = 224 (0xe0)<p>
<a name="checkcast_quick.Stack"></a>
<b>Stack</b><br>
<a name="12449"></a>
..., <i>objectref</i><em> </em><img src="chars/arrwdbrt.gif"> ..., <i>objectref</i><p>
<a name="checkcast_quick.Description"></a>
<b>Description</b><br>
<a name="5289"></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">(&#167;3.6)</a>, where the value of the index is (<i>indexbyte1</i> << 8) | <i>indexbyte2</i>. The object at that index of the constant pool must already have been successfully resolved and must be a class or interface type.<p>
<a name="18707"></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_quick</i> instruction throws a <code>ClassCastException</code>.<p>
<a name="18708"></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_quick</i> determines whether <i>objectref</i> can be cast to type T as follows:<p>
<ul><a name="11836"></a>
<li>If S is an ordinary (non-array) class, then:
<ul>
<a name="11840"></a>
<li>If T is a class type, then S must be the same class <a href="Concepts.doc.html#20389">(&#167;2.8.1)</a> as T, or S must be a subclass of T;
<a name="11844"></a>
<li>If T is an interface type, then S must implement <a href="Concepts.doc.html#16432">(&#167;2.13)</a> interface T.
<a name="22090"></a>
 <a href="Quick2.doc.html#">checkcast_quick	 (cont.)	checkcast_quick (cont.)</a><p>
</ul>
<a name="11845"></a>
<li>If S is a class representing the array type SC<code>[]</code>, that is, an array of components of type SC, then:
<ul>
<a name="11849"></a>
<li>If T is a class type, then T must be <code>Object</code> <a href="Concepts.doc.html#27433">(&#167;2.4.6)</a>.
<a name="11850"></a>
<li>If T is an array type TC<code>[]</code>, that is, an array of components of type TC, then one of the following must be true:
<ul>
<a name="11854"></a>
<li>TC and SC are the same primitive type <a href="Concepts.doc.html#19511">(&#167;2.4.1)</a>.
<a name="11858"></a>
<li>TC and SC are reference types <a href="Concepts.doc.html#25376">(&#167;2.4.5)</a> and type SC can be cast to TC by these runtime rules. 
</ul>
</ul>
</ul><a name="8098"></a>
S cannot be an interface type, because there are no instances of interfaces, only instances of classes and arrays.<p>
<a name="checkcast_quick.Runtime"></a>
<b>Runtime Exception</b><br>
<a name="12063"></a>
If <i>objectref</i><em> </em>cannot be cast to the type of the resolved class, the <i>checkcast_quick</i> instruction throws a <code>ClassCastException</code>.<p>
<a name="checkcast_quick.Notes"></a>
<b>Notes</b><br>
<a name="5295"></a>
The opcode of this instruction was originally <i>checkcast</i>. The operands of the <i>checkcast</i> instruction are not modified.<p>
<a name="8217"></a>
The <i>checkcast_quick</i> instruction is very similar to the <i>instanceof_quick</i> instruction. It differs in its treatment of <code>null</code>, its behavior when its test fails (<i>checkcast_quick</i> throws an exception, <i>instanceof_quick</i> pushes a result code), and its effect on the operand stack.<p>


<hr>
<!-- This inserts footnotes--><p><br>
<a href="Copyright.doc.html">Contents</a> | <a href="Quick2.doc.html">Prev</a> | <a href="Quick2.doc2.html">Next</a> | <a href="Lindholm.INDEX.html">Index</a>
<p>
<font size=-1>Java Virtual Machine Specification (HTML generated by chsieh on March 13, 1997)<br>
<i><a href="Copyright.doc.html">Copyright &#169 1996, 1997 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 + -