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

📄 instructions2.doc9.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=100%><tr>
<td><a href="VMSpecTOC.doc.html">Contents</a> | <a href="Instructions2.doc8.html">Prev</a> | <a href="Instructions2.doc10.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="monitorenter">
</a><h2>monitorenter</h2>
<a name="monitorenter.Operation"></a>
<b>Operation</h3></b>
<a name="69702"></a>
<p><Table Border="1">
<tr><td><a name="69701"></a>
 <i>monitorenter</i>
<td><a name="87568"></a>
 

</Table><br><br>Enter monitor for object<p>
<a name="monitorenter.Forms"></a>
<b>Forms</h3></b>
<a name="69703"></a>
<i>monitorenter</i> = 194 (0xc2)<p>
<a name="monitorenter.Stack"></a>
<b>Stack</h3></b>
<a name="69704"></a>
..., <i>objectref</i><em> </em><img src="chars/arrwdbrt.gif"> ... <p>
<a name="monitorenter.Description"></a>
<b>Description</h3></b>
<a name="69705"></a>
The <i>objectref</i> must be of type <code>reference</code>.<p>
<a name="69706"></a>
Each object has a monitor associated with it. The thread that executes <i>monitorenter</i> gains ownership of the monitor associated with <i>objectref</i>. If another thread already owns the monitor associated with <i>objectref</i>, the current thread waits until the object is unlocked, then tries again to gain ownership. If the current thread already owns the monitor associated with <i>objectref</i>, it increments a counter in the monitor indicating the number of times this thread has entered the monitor. If the monitor associated with <i>objectref</i> is not owned by any thread, the current thread becomes the owner of the monitor, setting the entry count of this monitor to 1.<p>
<a name="monitorenter.Runtime"></a>
<b>Runtime Exception</h3></b>
<a name="69708"></a>
If <i>objectref</i><em> </em>is <code>null</code>, <i>monitorenter</i> throws a <code>NullPointerException</code>. <p>
<a name="monitorenter.Notes"></a>
<b>Notes</h3></b>
<a name="131155"></a>
For detailed information about threads and monitors in the Java Virtual Machine, see Chapter <a href="Threads.doc.html#21293">8</a>, <a href="Threads.doc.html#21294">"Threads and Locks."</a><p>

The <i>monitorenter</i> instruction may be used with a <i>monitorexit</i> instruction to implement a Java <code>synchronized</code> block. The <i>monitorenter</i> instruction is not used in the implementation of <code>synchronized</code> methods, although it provides equivalent semantics; monitor entry on invocation of a <code>synchronized</code> method is handled implicitly by the Java Virtual Machine's method invocation instructions. See <a href="Compiling.doc.html#6530">&#167;7.14</a>, in <a href="Compiling.doc.html#2989">"Compiling for the Java Virtual Machine,"</a> for more information on the use of the <i>monitorenter</i> and <i>monitorexit</i> instructions.<p>
<a name="125548"></a>
The association of a monitor with an object may be managed in various ways that are beyond the scope of this specification. For instance, the monitor may be allocated and deallocated at the same time as the object. Alternatively, it may be dynamically allocated at the time when a thread attempts to gain exclusive access to the object and freed at some later time when no thread remains in the monitor for the object.<p>
<a name="125547"></a>
The synchronization constructs of the Java Language require support for operations on monitors besides entry and exit, including waiting on a monitor (<code>Object.wait</code>) and notifying other threads waiting in a monitor (<code>Object.notify</code> and <code>Object.notifyAll</code>). These operations are supported in the standard package <code>java.lang</code>, supplied with the Java Virtual Machine. No explicit support for these operations appears in the instruction set of the Java Virtual Machine.<p>

<a name="monitorexit"></a>
<hr><h2>monitorexit</h2>
<a name="monitorexit.Operation"></a>
<b>Operation</h3></b>
<a name="69724"></a>
<p><Table Border="1">
<tr><td><a name="69723"></a>
 <i>monitorexit</i>
<td><a name="87568"></a>
 

</Table><br><br>Exit monitor for object<p>
<a name="monitorexit.Forms"></a>
<b>Forms</h3></b>
<a name="69725"></a>
<i>monitorexit</i> = 195 (0xc3)<p>
<a name="monitorexit.Stack"></a>
<b>Stack</h3></b>
<a name="69726"></a>
..., <i>objectref</i><em> </em><img src="chars/arrwdbrt.gif"> ... <p>
<a name="monitorexit.Description"></a>
<b>Description</h3></b>
<a name="69727"></a>
The <i>objectref</i> must be of type <code>reference</code>.<p>
<a name="69728"></a>
The current thread must be the owner of the monitor associated with the instance referenced by <i>objectref</i>. The thread decrements the counter indicating the number of times it has entered this monitor. If as a result the value of the counter becomes zero, the current thread releases the monitor. If the monitor associated with <i>objectref</i> becomes free, other threads that are waiting to acquire that monitor are allowed to attempt to do so.<p>
<a name="monitorexit.Runtime"></a>
<b>Runtime Exceptions</h3></b>
<a name="69730"></a>
If <i>objectref</i><em> </em>is <code>null</code>, <i>monitorexit</i> throws a <code>NullPointerException</code>. <p>
<a name="69731"></a>
Otherwise, if the current thread is not the owner of the monitor, <i>monitorexit</i> throws an <code>IllegalMonitorStateException</code>.<p>
<a name="monitorexit.Notes"></a>
<b>Notes</h3></b>
<a name="131165"></a>
For detailed information about threads and monitors in the Java Virtual Machine, see Chapter <a href="Threads.doc.html#21293">8</a>, <a href="Threads.doc.html#21294">"Threads and Locks."</a><p>
The <i>monitorenter</i> and <i>monitorexit</i> instructions may be used to implement Java's <code>synchronized</code> blocks. The <i>monitorexit</i> instruction is not used in the implementation of <code>synchronized</code> methods, although it provide equivalent semantics; monitor exit on normal or abnormal <code>synchronized</code> method completion is handled implicitly by the Java Virtual Machine's method invocation instructions. The Java Virtual Machine also implicitly handles monitor exit from within a <code>synchronized</code> block when an error is thrown. See <a href="Compiling.doc.html#6530">&#167;7.14</a>, in <a href="Compiling.doc.html#2989">"Compiling for the Java Virtual Machine,"</a> for more information on the use of the <i>monitorenter</i> and <i>monitorexit</i> instructions.<p>

<a name="multianewarray"></a>
<hr><h2>multianewarray</h2>
<a name="multianewarray.Operation"></a>
<b>Operation</h3></b>
<a name="69744"></a>
Create new multidimensional array<p><Table Border="1">
<tr><td><a name="69737"></a>
 <i>multianewarray</i>
<td><a name="87568"></a>
 

<tr><td><a name="69739"></a>
 <i>indexbyte1</i>
<td><a name="87568"></a>
 

<tr><td><a name="69741"></a>
 <i>indexbyte2</i>
<td><a name="87568"></a>
 

<tr><td><a name="69743"></a>
 <i>dimensions</i>
<td><a name="87568"></a>
 

</Table><br><br><p>
<a name="multianewarray.Forms"></a>
<b>Forms</h3></b>
<a name="69745"></a>
<i>multianewarray</i> = 197 (0xc5)<p>
<a name="multianewarray.Stack"></a>
<b>Stack</h3></b>
<a name="69746"></a>
...,<em> </em><i>count1</i>, [<i>count2</i>,<em> </em>...]<em> </em><img src="chars/arrwdbrt.gif"> ..., <i>arrayref</i><p>
<a name="multianewarray.Description"></a>
<b>Description</h3></b>
<a name="69747"></a>
The <i>dimensions</i> is an unsigned byte which must be greater than or equal to 1. It represents the number of dimensions of the array to be created. The operand stack must contain <i>dimensions</i> words, which must be of type <code>int</code> and nonnegative, each representing the number of components in a dimension of the array to be created. The <i>count1</i> is the desired length in the first dimension, <i>count2</i> in the second, etc.<p>
<a name="104839"></a>
All of the <i>count</i> values are popped off the operand stack. 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 item at that index in the constant pool must be a <code>CONSTANT_Class</code> <a href="ClassFile.doc.html#1221">(&#167;4.4.1)</a>. The symbolic reference is resolved <a href="ConstantPool.doc.html#65204">(&#167;5.1.3)</a>. The resulting entry must be an array class type of dimensionality greater than or equal to <i>dimensions</i>.<p>
A new multidimensional array of the array type is allocated from the garbage-collected heap. The components of the array of in the first dimension are initialized to subarrays of the type of the second dimension, and so on. The components of the first dimension of the array are initialized to the default initial value for the type of the components (<a href="Concepts.doc.html#15858">&#167;2.5.1</a>). A <code>reference</code> <i>arrayref</i> to the new array is pushed onto the operand stack. <p>
<a name="multianewarray.Linking"></a>
<b>Linking Exceptions</h3></b>
<a name="119072"></a>
During resolution of the <code>CONSTANT_Class</code> constant pool item, any of the exceptions documented in <a href="ConstantPool.doc.html#51579">&#167;5.1</a> can be thrown.<p>
<a name="69765"></a>
Otherwise, if the current class does not have permission to access the base class of the resolved array class, <i>multianewarray</i> throws an <code>IllegalAccessError</code>.<p>
<a name="multianewarray.Runtime"></a>
<b>Runtime Exception</h3></b>
<a name="69770"></a>
Otherwise, if any of the <i>dimensions</i> values on the operand stack is less than zero, the <i>multianewarray</i> instruction throws a <code>NegativeArraySizeException</code>.<p>
<a name="multianewarray.Notes"></a>
<b>Notes</h3></b>
<a name="69772"></a>
It may be more efficient to use <i>newarray</i> or <i>anewarray</i> when creating an array of a single dimension.<p>
<a name="69773"></a>
The array class referenced via the constant pool instruction may have more dimensions than the <i>dimensions</i> operand of the <i>multianewarray</i> instruction. In that case, only the first <i>dimensions</i> of the dimensions of the array are created.<p>


<hr>
<!-- This inserts footnotes--><p>
<a href="VMSpecTOC.doc.html">Contents</a> | <a href="Instructions2.doc8.html">Prev</a> | <a href="Instructions2.doc10.html">Next</a> | <a href="Lindholm.INDEX.html">Index</a>
<p>
<font size = -1>Java Virtual Machine Specification <br>
<!--(HTML generated by dkramer on March 31, 1997)-->
<!--
(HTML generated by dkramer on March 25, 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:jvm@java.sun.com">jvm@java.sun.com</a>
</font>
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -