📄 instructions2.doc102.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.doc101.html">Prev</a> | <a href="Instructions2.doc103.html">Next</a> | <a href="Mnemonics.doc.html">Index</a><hr><br> <a name="instanceof"></a><h2>instanceof</h2><ul><a name="68741"></a><li>If S is an ordinary (non-array) class, then:<ul><a name="68745"></a><li>If T is a class type, then S must be the same class <a href="Concepts.doc.html#20389">(§2.8.1)</a> as T or a subclass of T.<a name="68749"></a><li>If T is an interface type, then S must implement <a href="Concepts.doc.html#16432">(§2.13)</a> interface T.</ul><a name="68750"></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="68754"></a><li>If T is a class type, then T must be <code>Object</code> <a href="Concepts.doc.html#27433">(§2.4.6)</a>.<a name="68755"></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="68759"></a><li>TC and SC are the same primitive type <a href="Concepts.doc.html#19511">(§2.4.1)</a>.<a name="68763"></a><li>TC and SC are reference types <a href="Concepts.doc.html#25376">(§2.4.5)</a>, and type SC can be cast to TC by these runtime rules. </ul></ul></ul><a name="68764"></a>S cannot be an interface type, because there are no instances of interfaces, only instances of classes and arrays.<p><a name="instanceof.Linking"></a><b>Linking Exceptions</b><br><a name="115905"></a>During resolution of the <code>CONSTANT_Class</code> constant pool item, any of the exceptions documented in <a href="ConstantPool.doc.html#51579">§5.1</a> can be thrown.<p><a name="instanceof.Notes"></a><b>Notes</b><br><a name="68766"></a>The <i>instanceof</i> instruction is fundamentally very similar to the <i>checkcast</i> instruction. It differs in its treatment of <code>null</code>, its behavior when its test fails (<i>checkcast</i> throws an exception, <i>instanceof</i> pushes a result code), and its effect on the operand stack.<p><a name="68767"></a><p><hr><!-- This inserts footnotes--><p><a href="VMSpecTOC.doc.html">Contents</a> | <a href="Instructions2.doc101.html">Prev</a> | <a href="Instructions2.doc103.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 + -