📄 instructions2.doc.html
字号:
<tr><td><a name="67178"></a> <i>indexbyte1</i><td><a name="87568"></a> <tr><td><a name="67180"></a> <i>indexbyte2</i><td><a name="87568"></a> </Table><br></blockquote><p><a name="anewarray.Forms"></a><p><b>Forms</b><br><blockquote><a name="67182"></a><i>anewarray</i> = 189 (0xbd)</blockquote><p><a name="anewarray.Operand"></a><p><b>Operand Stack</b><br><blockquote><a name="67183"></a>..., <i>count</i> <img src="chars/arrwdbrt.gif"> ..., <i>arrayref</i></blockquote><p><a name="anewarray.Description"></a><p><b>Description</b><br><blockquote><a name="416596"></a>The <i>count</i> must be of type <code>int</code>. It is popped off the operand stack. The <i>count</i> represents the number of components of the array to be created. The unsigned <i>indexbyte1</i> and <i>indexbyte2</i> are used to construct an index into the runtime 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 runtime constant pool item at that index must be a symbolic reference to a class, array, or interface type. The named class, array, or interface type is resolved <a href="ConstantPool.doc.html#71636">(§5.4.3.1)</a>. A new array with components of that type, of length <i>count</i>, is allocated from the garbage-collected heap, and a <code>reference</code> <i>arrayref</i> to this new array object is pushed onto the operand stack. All components of the new array are initialized to <code>null</code>, the default value for <code>reference</code> types <a href="Concepts.doc.html#15858">(§2.5.1)</a>.</blockquote><p><a name="anewarray.Linking"></a><p><b>Linking Exceptions</b><br><blockquote><a name="109456"></a>During resolution of the symbolic reference to the class, array, or interface type, any of the exceptions documented in <a href="ConstantPool.doc.html#71636">§5.4.3.1</a> can be thrown.</blockquote><p><a name="anewarray.Runtime"></a><p><b>Runtime Exception</b><br><blockquote><a name="67198"></a>Otherwise, if <i>count</i><em> </em>is less than zero, the <i>anewarray</i> instruction throws a <code>NegativeArraySizeException</code>. </blockquote><p><a name="anewarray.Notes"></a><p><b>Notes</b><br><blockquote><a name="476057"></a>The <i>anewarray</i> instruction is used to create a single dimension of an array of object references or part of a multidimensional array.</blockquote><p><a name="areturn"></a><hr><h2>areturn</h2><a name="areturn.Operation"></a><p><b>Operation</b><br><blockquote><a name="67210"></a>Return <code>reference</code> from method<p><Table Border="1"></blockquote><p><b>Format</b><br><blockquote><tr><td><a name="67209"></a> <i>areturn</i><td><a name="87568"></a> </Table><br></blockquote><p><a name="areturn.Forms"></a><p><b>Forms</b><br><blockquote><a name="67211"></a><i>areturn</i> = 176 (0xb0)</blockquote><p><a name="areturn.Operand"></a><p><b>Operand Stack</b><br><blockquote><a name="67212"></a>..., <i>objectref</i><em> </em><img src="chars/arrwdbrt.gif"> [empty]</blockquote><p><a name="areturn.Description"></a><p><b>Description</b><br><blockquote><a name="67213"></a>The <i>objectref</i> must be of type <code>reference</code> and must refer to an object of a type that is assignment compatible <a href="Concepts.doc.html#19674">(§2.6.7)</a> with the type represented by the return descriptor <a href="ClassFile.doc.html#7035">(§4.3.3)</a> of the current method. If the current method is a <code>synchronized</code> method, the monitor acquired or reentered on invocation of the method is released or exited (respectively) as if by execution of a <i>monitorexit</i> instruction. If no exception is thrown, <i>objectref</i> is popped from the operand stack of the current frame <a href="Overview.doc.html#17257">(§3.6)</a> and pushed onto the operand stack of the frame of the invoker. Any other values on the operand stack of the current method are discarded.</blockquote><p><blockquote><a name="67223"></a>The interpreter then reinstates the frame of the invoker and returns control to the invoker.</blockquote><p><a name="areturn.Runtime"></a><p><b>Runtime Exceptions</b><br><blockquote><a name="244779"></a>If the current method is a <code>synchronized</code> method and the current thread is not the owner of the monitor acquired or reentered on invocation of the method, <i>areturn</i> throws an <code>IllegalMonitorStateException</code>. This can happen, for example, if a <code>synchronized</code> method contains a <i>monitorexit</i> instruction, but no <i>monitorenter</i> instruction, on the object on which the method is synchronized.</blockquote><p><blockquote><a name="250686"></a>Otherwise, if the virtual machine implementation enforces the rules on structured use of locks described in <a href="Threads.doc.html#22500">§8.13</a> and if the first of those rules is violated during invocation of the current method, then <i>areturn</i> throws an <code>IllegalMonitorStateException</code>.</blockquote><p><a name="arraylength"></a><hr><h2>arraylength</h2><a name="arraylength.Operation"></a><p><b>Operation</b><br><blockquote>Get length of array<a name="339546"></a><p><Table Border="1"></blockquote><p><b>Format</b><br><blockquote><tr><td><a name="339542"></a> <i>arraylength</i><td><a name="339544"></a> </Table><br></blockquote><p><a name="arraylength.Forms"></a><p><b>Forms</b><br><blockquote><a name="67231"></a><i>arraylength</i> = 190 (0xbe)</blockquote><p><a name="arraylength.Operand"></a><p><b>Operand Stack</b><br><blockquote><a name="67232"></a>..., <i>arrayref</i><em> </em><img src="chars/arrwdbrt.gif"> ..., <i>length</i></blockquote><p><a name="arraylength.Description"></a><p><b>Description</b><br><blockquote><a name="67233"></a>The <i>arrayref</i> must be of type <code>reference</code> and must refer to an array. It is popped from the operand stack. The <i>length</i> of the array it references is determined. That <i>length</i> is pushed onto the operand stack as an <code>int</code>.</blockquote><p><a name="arraylength.Runtime"></a><p><b>Runtime Exception</b><br><blockquote><a name="67235"></a>If the <i>arrayref</i><em> </em>is <code>null</code>, the <i>arraylength</i> instruction throws a <code>NullPointerException</code>. </blockquote><p><a name="astore"></a><hr><h2>astore</h2><a name="astore.Operation"></a><p><b>Operation</b><br><blockquote><a name="67244"></a>Store <code>reference</code> into local variable<p><Table Border="1"></blockquote><p><b>Format</b><br><blockquote><tr><td><a name="67241"></a> <i>astore</i><td><a name="87568"></a> <tr><td><a name="67243"></a> <i>index</i><td><a name="87568"></a> </Table><br></blockquote><p><a name="astore.Forms"></a><p><b>Forms</b><br><blockquote><a name="67245"></a><i>astore</i> = 58 (0x3a)</blockquote><p><a name="astore.Operand"></a><p><b>Operand Stack</b><br><blockquote><a name="67246"></a>..., <i>objectref</i> <img src="chars/arrwdbrt.gif"> ...</blockquote><p><a name="astore.Description"></a><p><b>Description</b><br><blockquote><a name="67247"></a>The <i>index</i> is an unsigned byte that must be an index into the local variable array of the current frame <a href="Overview.doc.html#17257">(§3.6)</a>. The <i>objectref</i> on the top of the operand stack must be of type <code>returnAddress</code> or of type <code>reference</code>. It is popped from the operand stack, and the value of the local variable at <i>index</i> is set to <i>objectref</i>.</blockquote><p><a name="astore.Notes"></a><p><b>Notes</b><br><blockquote><a name="67251"></a>The <i>astore</i> instruction is used with an <i>objectref</i> of type <code>return</code><code>Address</code> when implementing the <code>finally</code> clauses of the Java programming language (see <a href="Compiling.doc.html#13789">Section 7.13, "Compiling <code>finally</code>"</a>). The <i>aload</i> instruction cannot be used to load a value of type <code>returnAddress</code> from a local variable onto the operand stack. This asymmetry with the <i>astore</i> instruction is intentional.</blockquote><p><blockquote><a name="67255"></a>The <i>astore</i> opcode can be used in conjunction with the <i>wide</i> instruction to access a local variable using a two-byte unsigned index.</blockquote><p><a name="astore_n"></a><hr><h2>astore_<n></h2><a name="astore_n.Operation"></a><p><b>Operation</b><br><blockquote>Store <code>reference</code> into local variable<a name="67265"></a><p><Table Border="1"></blockquote><p><b>Format</b><br><blockquote><tr><td><a name="67264"></a> <i>astore_<n></i><td><a name="87568"></a> </Table><br></blockquote><p><a name="astore_n.Forms"></a><p><b>Forms</b><br><blockquote><a name="67266"></a><i>astore_0</i> = 75 (0x4b) <i>astore_1</i> = 76 (0x4c) <i>astore_2</i> = 77 (0x4d) <i>astore_3</i> = 78 (0x4e)</blockquote><p><a name="astore_n.Operand"></a><p><b>Operand Stack</b><br><blockquote><a name="67267"></a>..., <i>objectref</i> <img src="chars/arrwdbrt.gif"> ...</blockquote><p><a name="astore_n.Description"></a><p><b>Description</b><br><blockquote><a name="67268"></a>The <i><n></i> must be an index into the local variable array of the current frame <a href="Overview.doc.html#17257">(§3.6)</a>. The <i>objectref</i> on the top of the operand stack must be of type <code>returnAddress</code> or of type <code>reference</code>. It is popped from the operand stack, and the value of the local variable at <i><n></i> is set to <i>objectref</i>.</blockquote><p><a name="astore_n.Notes"></a><p><b>Notes</b><br><blockquote><a name="67272"></a>An <i>astore_<n></i> instruction is used with an <i>objectref</i> of type <code>returnAddress</code> when implementing the <code>finally</code> clauses of the Java programming language (see <a href="Compiling.doc.html#13789">Section 7.13, "Compiling <code>finally</code>"</a>). An <i>aload_<n></i> instruction cannot be used to load a value of type <code>returnAddress</code> from a local variable onto the operand stack. This asymmetry with the corresponding <i>astore_<n></i> instruction is intentional.</blockquote><p><blockquote><a name="67276"></a>Each of the <i>astore_<n></i> instructions is the same as <i>astore</i> with an <i>index</i> of <i><n></i>, except that the operand <i><n></i> is implicit.</blockquote><p><a name="athrow"></a><hr><h2>athrow</h2><a name="athrow.Operation"></a><p><b>Operation</b><br><blockquote><a name="67283"></a>Throw exception or error<p><Table Border="1"></blockquote><p><b>Format</b><br><blockquote><tr><td><a name="67282"></a> <i>athrow</i><td><a name="87568"></a> </Table><br> </blockquote><p><a name="athrow.Forms"></a><p><b>Forms</b><br><blockquote><a name="67284"></a><i>athrow</i> = 191 (0xbf)</blockquote><p><a name="athrow.Operand"></a><p><b>Operand Stack</b><br><blockquote><a name="67285"></a>..., <i>objectref</i><em> </em><img src="chars/arrwdbrt.gif"> <i>objectref</i></blockquote><p><a name="athrow.Description"></a><p><b>Description</b><br><blockquote><a name="67286"></a>The <i>objectref</i> must be of type <code>reference</code> and must refer to an object that is an instance of class <code>Throwable</code> or of a subclass of <code>Throwable</code>. It is popped from the operand stack. The <i>objectref</i> is then thrown by searching the current method <a href="Overview.doc.html#17257">(§3.6)</a> for the first exception handler that matches the class of <i>objectref</i>, as given by the algorithm in <a href="Overview.doc.html#15494">§3.10</a>.</blockquote><p><blockquote><a name="157182"></a>If an exception handler that matches <i>objectref</i> is found, it contains the location of the code intended to handle this exception. The <code>pc</code> register is reset to that location, the operand stack of the current frame is cleared, <i>objectref</i> is pushed back onto the operand stack, and execution continues. </blockquote><p><blockquote><a name="265460"></a>If no matching exception handler is found in the current frame, that frame is popped. If the current frame represents an invocation of a <code>synchronized</code> method, the monitor acquired or reentered on invocation of the method is released or exited (respectively) as if by execution of a <i>monitorexit</i> instruction. Finally, the frame of its invoker is reinstated, if such a frame exists, and the <i>objectref</i> is rethrown. If no such frame exists, the current thread exits.</blockquote><p><a name="athrow.Runtime"></a><p><b>Runtime Exceptions</b><br><blockquote><a name="67293"></a>If <i>objectref</i><em> </em>is <code>null</code>, <i>athrow</i> throws a <code>NullPointerException</code> instead of <i>objectref</i>.</blockquote><p><blockquote><a name="488406"></a>Otherwise, if the method of the current frame is a <code>synchronized</code> method and the current thread is not the owner of the monitor acquired or reentered on invocation of the method, <i>athrow</i> throws an <code>IllegalMonitorStateException</code> instead of the object previously being thrown. This can happen, for example, if an abruptly completing <code>synchronized</code> method contains a <i>monitorexit</i> instruction, but no <i>monitorenter</i> instruction, on the object on which the method is synchronized.</blockquote><p><blockquote><a name="255762"></a>Otherwise, if the virtual machine implementation enforces the rules on structured use of locks described in <a href="Threads.doc.html#22500">§8.13</a> and if the first of those rules is violated during invocation of the current method, then <i>athrow</i> throws an <code>IllegalMonitorStateException</code> instead of the object previously being thrown.</blockquote><p><a name="athrow.Notes"></a><p><b>Notes</b><br><blockquote><a name="255756"></a>The operand stack diagram for the <i>athrow</i> instruction may be misleading: If a handler for this exception is matched in the current method, the <i>athrow</i> instruction discards all the values on the operand stack, then pushes the thrown object onto the operand stack. However, if no handler is matched in the current method and the exception is thrown farther up the method invocation chain, then the operand stack of the method (if any) that handles the exception is cleared and <i>objectref</i> is pushed onto that empty operand stack. All intervening frames from the method that threw the exception up to, but not including, the method that handles the exception are discarded.</blockquote><p><hr><!-- This inserts footnotes--><p><a href="VMSpecTOC.doc.html">Contents</a> | <a href="Instructions.doc.html">Prev</a> | <a href="Instructions2.doc1.html">Next</a> | <a href="VMSpecIX.fm.html">Index</a><p><font size="-1"><i>The Java</i><sup><font size=-2>TM</font></sup><i> Virtual Machine Specification </i><br><!-- HTML generated by Suzette Pelouch on March 30, 1999 --><i><a href="Copyright.doc.html">Copyright © 1999 Sun Microsystems, Inc.</a>All rights reserved</i><br>Please send any comments or corrections to <a href="mailto:jvm@java.sun.com">jvm@java.sun.com</a></font></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -