📄 instructions2.doc7.html
字号:
<a name="ineg"></a>
<hr><h2>ineg</h2>
<a name="ineg.Operation"></a>
<b>Operation</h3></b>
<a name="68687"></a>
Negate <code>int</code><p><Table Border="1">
<tr><td><a name="68686"></a>
<i>ineg</i>
<td><a name="87568"></a>
</Table><br><br><p>
<a name="ineg.Forms"></a>
<b>Forms</h3></b>
<a name="68688"></a>
<i>ineg</i><em> </em>= 116 (0x74)<p>
<a name="ineg.Stack"></a>
<b>Stack</h3></b>
<a name="68689"></a>
..., <i>value</i><em> </em><img src="chars/arrwdbrt.gif"> ..., <i>result</i><p>
<a name="ineg.Description"></a>
<b>Description</h3></b>
<a name="68690"></a>
The <i>value</i> must be of type <code>int</code>. It is popped from the operand stack. The <code>int</code> <i>result</i> is the arithmetic negation of <i>value</i>, -<i>value</i>. The <i>result</i> is pushed onto the operand stack.<p>
<a name="68691"></a>
For <code>int</code> values, negation is the same as subtraction from zero. Because the Java Virtual Machine uses two's-complement representation for integers and the range of two's-complement values is not symmetric, the negation of the maximum negative <code>int</code> results in that same maximum negative number. Despite the fact that overflow has occurred, no exception is thrown. <p>
<a name="68692"></a>
For all <code>int</code> values <code>x</code>, <code>-x</code> equals <code>(~x) + 1</code>.<p>
<a name="instanceof"></a>
<hr><h2>instanceof</h2>
<a name="instanceof.Operation"></a>
<b>Operation</h3></b>
<a name="68727"></a>
<p><Table Border="1">
<tr><td><a name="68722"></a>
<i>instanceof</i>
<td><a name="87568"></a>
<tr><td><a name="68724"></a>
<i>indexbyte1</i>
<td><a name="87568"></a>
<tr><td><a name="68726"></a>
<i>indexbyte2</i>
<td><a name="87568"></a>
</Table><br><br>Determine if object is of given type<p>
<a name="instanceof.Forms"></a>
<b>Forms</h3></b>
<a name="68728"></a>
<i>instanceof</i> = 193 (0xc1)<p>
<a name="instanceof.Stack"></a>
<b>Stack</h3></b>
<a name="68729"></a>
..., <i>objectref</i><em> </em><img src="chars/arrwdbrt.gif"> ..., <i>result</i><p>
<a name="instanceof.Description"></a>
<b>Description</h3></b>
<a name="68730"></a>
The <i>objectref</i>, which must be of type <code>reference</code>, is popped from 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">(§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">(§4.4.1)</a>, a symbolic reference to a class, array, or interface. The symbolic reference is resolved <a href="ConstantPool.doc.html#51579">(§5.1)</a>. <p>
<a name="140275"></a>
If <i>objectref</i> is not <code>null</code> and is an instance of the resolved class, array, or interface, the <i>instanceof</i> instruction pushes an <code>int</code> <i>result</i> of <i>1</i> as an int on the operand stack. Otherwise, it pushes an <code>int</code> <i>result</i> of <i>0</i>.<p>
<a name="68740"></a>
The following rules are used to determine whether an <i>objectref</i> that is not <code>null</code> is an instance of 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>instanceof</i> determines whether <i>objectref</i> is an instance of T as follows:<p>
<a name="instanceof"></a>
<hr><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</h3></b>
<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</h3></b>
<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>
<a name="invokeinterface"></a>
<hr><h2>invokeinterface</h2>
<a name="invokeinterface.Operation"></a>
<b>Operation</h3></b>
<a name="68788"></a>
Invoke interface method<p><Table Border="1">
<tr><td><a name="68779"></a>
<i>invokeinterface</i>
<td><a name="87568"></a>
<tr><td><a name="68781"></a>
<i>indexbyte1</i>
<td><a name="87568"></a>
<tr><td><a name="68783"></a>
<i>indexbyte2</i>
<td><a name="87568"></a>
<tr><td><a name="68785"></a>
<i>nargs</i>
<td><a name="87568"></a>
<tr><td><a name="68787"></a>
<i>0</i>
<td><a name="87568"></a>
</Table><br><br><p>
<a name="invokeinterface.Forms"></a>
<b>Forms</h3></b>
<a name="68789"></a>
<i>invokeinterface</i> = 185 (0xb9)<p>
<a name="invokeinterface.Stack"></a>
<b>Stack</h3></b>
<a name="68790"></a>
...<em>, </em><i>objectref</i><em>, [</em><i>arg1</i><em>, [</em><i>arg2</i><em> </em>...<em>]] </em><img src="chars/arrwdbrt.gif"> ...<p>
<a name="invokeinterface.Description"></a>
<b>Description</h3></b>
<a name="68791"></a>
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 item at that index in the constant pool must have the tag <code>CONSTANT_InterfaceMethodref</code> <a href="ClassFile.doc.html#4723">(§4.4.2)</a>, a reference to an interface name, a method name, and the method's descriptor <a href="ClassFile.doc.html#7035">(§4.3.3)</a>. The constant pool item is resolved <a href="ConstantPool.doc.html#64064">(§5.3)</a>. The interface method must not be <code><init></code>, an instance initialization method <a href="Overview.doc.html#12174">(§3.8)</a>, or <code><clinit></code>, a class or interface initialization method <a href="Overview.doc.html#12174">(§3.8)</a>. <p>
<a name="68804"></a>
The <i>nargs</i> operand is an unsigned byte which must not be zero. The <i>objectref</i> must be of type <code>reference</code> and must be followed on the operands stack by <i>nargs</i> - 1 words of arguments. The number of words of arguments and the type and order of the values they represent must be consistent with the descriptor of the selected interface method.<p>
<a name="68805"></a>
The method table of the class of the type of <i>objectref</i> is determined. If <i>objectref</i> is an array type, then the method table of class <code>Object</code> is used. The method table is searched for a method whose name and descriptor are identical to the name and descriptor of the resolved constant pool entry.<p>
The result of the search is a method table entry, which includes a direct reference to the code for the interface method and the method's modifier information (see <a href="ClassFile.doc.html#12725">Table 4.4, "Method access and modifier flags"</a>). The method table entry must be that of a <code>public</code> method.<p>
<a name="138160"></a>
If the method is <code>synchronized</code>, the monitor associated with <i>objectref</i> is acquired.<p>
<a name="138161"></a>
If the method is not <code>native</code>, the <i>nargs </i>- 1 words of arguments and <i>objectref</i> are popped from the operand stack. A new stack frame is created for the method being invoked, and <i>objectref</i> and the words of arguments are made the values of its first <i>nargs</i> local variables, with <i>objectref</i> in local variable <i>0</i>, <i>arg1</i> in local variable <i>1</i>, and so on. The new stack frame is then made current, and the Java Virtual Machine <code>pc</code> is set to the opcode of the first instruction of the method to be invoked. Execution continues with the first instruction of the method.<p>
<a name="138162"></a>
If the method is <code>native</code> and the platform-dependent code that implements it has not yet been loaded and linked into the Java Virtual Machine, that is done. The <i>nargs </i>- 1 words of arguments and <i>objectref</i> are popped from the operand stack; the code that implements the method is invoked in an implementation-dependent manner.<p>
<a name="invokeinterface.Linking"></a>
<b>Linking Exceptions</h3></b>
<a name="116277"></a>
During resolution of the <code>CONSTANT_InterfaceMethodref</code> constant pool item, any of the exceptions documented in <a href="ConstantPool.doc.html#64064">§5.3</a> can be thrown.<p>
<a name="68810"></a>
Otherwise, if no method matching the resolved name and descriptor can be found in the class of <i>objectref</i>, <i>invokeinterface</i> throws an <code>IncompatibleClassChangeError</code>.<p>
<a name="68811"></a>
Otherwise, if the selected method is a class (<code>static</code>) method, the <i>invokeinterface</i> instruction throws an <code>IncompatibleClass-ChangeError</code>.<p>
<a name="invokeinterface"></a>
<hr><h2>invokeinterface</h2>
<a name="68812"></a>
Otherwise, if the selected method is not <code>public</code>, <i>invokeinterface</i> throws an <code>IllegalAccessError</code>.<p>
<a name="68813"></a>
Otherwise, if the selected method is <code>abstract</code>, <i>invokeinterface</i> throws an <code>AbstractMethodError</code>.<p>
<a name="68814"></a>
Otherwise, if the selected method is <code>native</code> and the code that implements the method cannot be loaded or linked, <i>invokeinterface</i> throws an <code>UnsatisfiedLinkError</code>.<p>
<a name="invokeinterface.Runtime"></a>
<b>Runtime Exception</h3></b>
<a name="68816"></a>
Otherwise, if <i>objectref</i> is <code>null</code>, the <i>invokeinterface</i> instruction throws a <code>NullPointerException</code>. <p>
<a name="invokeinterface.Notes"></a>
<b>Notes</h3></b>
<a name="68823"></a>
Unlike <i>invokevirtual</i>, <i>invokestatic</i>, and <i>invokespecial</i>, the number of arguments words (<i>nargs</i>) for the method invocation is made available as an operand of the <i>invokeinterface</i> instruction. As with the other instructions, that value can also be derived from the descriptor of the selected method. The derived value must be identical to the value of the <i>nargs</i> operand. This redundancy is historical, but the <i>nargs</i> operand also reserves space in the instruction for an operand used by the <i>invokeinterface_quick</i> pseudo-instruction which may replace <i>invokeinterface</i> at run time. See Chapter <a href="Quick.doc.html#2488">9</a>, <a href="Quick.doc.html#6997">"An Optimization,"</a> for information on <i>invokeinterface_quick</i>.<p>
<a name="68827"></a>
The fourth operand byte of the <i>invokeinterface</i> instruction is unused by the instruction itself and must be zero. It exists only to reserve space for an additional operand added if the <i>invokeinterface</i> instruction is replaced by the <i>invokeinterface_quick</i> pseudo-instruction at run time. <p>
<a name="invokespecial"></a>
<hr><h2>invokespecial</h2>
<a name="invokespecial.Operation"></a>
<b>Operation</h3></b>
<a name="68833"></a>
Invoke instance method; special handling for superclass, private, and instance initialization method invocations<p><Table Border="1">
<tr><td><a name="68838"></a>
<i>invokespecial</i>
<td><a name="87568"></a>
<tr><td><a name="68840"></a>
<i>indexbyte1</i>
<td><a name="87568"></a>
<tr><td><a name="68842"></a>
<i>indexbyte2</i>
<td><a name="87568"></a>
</Table><br><br><p>
<a name="invokespecial.Forms"></a>
<b>Forms</h3></b>
<a name="68843"></a>
<i>invokespecial</i> = 183 (0xb7)<p>
<a name="invokespecial.Stack"></a>
<b>Stack</h3></b>
<a name="68844"></a>
...<em>, </em><i>objectref</i><em>, [</em><i>arg1</i><em>, [</em><i>arg2</i><em> </em>...<em>]] </em><img src="chars/arrwdbrt.gif"> ...<p>
<a name="invokespecial.Description"></a>
<b>Description</h3></b>
<a name="68845"></a>
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 item at that index in the constant pool must have the tag <code>CONSTANT_Methodref</code> <a href="ClassFile.doc.html#4723">(§4.4.2)</a>, a reference to a class name, a method name, and the method's descriptor <a href="ClassFile.doc.html#7035">(§4.3.3)</a>. The named method is resolved <a href="ConstantPool.doc.html#49425">(§5.2)</a>. The descriptor of the resolved method must be identical to the descriptor of one of the methods of the resolved class. <p>
<a name="68858"></a>
Next, the Java Virtual Machine determines if all of the following conditions are true:<p>
<ul><a name="68859"></a>
<li>The name of the method is not <code><init></code>, an instance initialization method <a href="Overview.doc.html#12174">(§3.8)</a>.
<a name="68860"></a>
<li>The method is not a <code>private</code> method.
<a name="68861"></a>
<li>The class of the method is a superclass of the class of the current method.
<a name="68864"></a>
<li>The <code>ACC_SUPER </code>flag (see <a href="ClassFile.doc.html#23242">Table 4.1, "Class access and modifier flags"</a>) is set for the current class.
</ul>
If so, then the Java Virtual Machine selects the method with the identical descriptor in the closest superclass, possibly selecting the method just resolved.<p>
<a name="68867"></a>
The resulting method must not be <code><clinit></code>, a class or interface initialization method <a href="Overview.doc.html#12174">(§3.8)</a>. <p>
<a name="140201"></a>
If the method is <code><init></code>, an instance initialization method <a href="Overview.doc.html#12174">(§3.8)</a>, then the method must only be invoked once on an uninitialized object, and before the first backward branch following the execution of the <i>new</i> instruction that allocated the object. <p>
<a name="140202"></a>
Finally, if the method is <code>protected</code> <a href="ClassFile.doc.html#1513">(§4.6)</a>, then it must be either a member of the current class or a member of a superclass of the current class, and the class of <i>objectref</i> must be either the current class or a subclass of the current class.<p>
<a name="68872"></a>
The constant pool entry representing the resolved method includes a direct reference to the code for the method, an unsigned byte <i>nargs </i>that must not be zero, and the method's modifier information (see <a href="ClassFile.doc.html#12725">Table 4.4, "Method access and modifier flags"</a>).<p>
<a name="68873"></a>
The <i>objectref</i> must be of type <code>reference</code> and must be followed on the operand stack by <i>nargs </i>- 1 words of arguments, where the number of words of arguments and the type and order of the values they represent must be consistent with the descriptor of the selected instance method.<p>
<a name="138167"></a>
If the method is <code>synchronized</code>, the monitor associated with <i>objectref</i> is acquired.<p>
If the method is not <code>native</code>, the <i>nargs </i>- 1 words of arguments and <i>objectref</i> are popped from the operand stack. A new stack frame is created for the method being invoked, and <i>objectref</i> and the words of arguments are made the values of its first <i>nargs</i> local variables, with <i>objectref</i> in local variable <i>0</i>, <i>arg1</i> in local variable <i>1</i>, and so on. The new stack frame is then made current, and the Java Virtual Machine <code>pc</code> is set to the opcode of the first instruction of the method to be invoked. Execution continues with the first instruction of the method.<p>
<a name="138169"></a>
If the method is <code>native</code> and the platform-dependent code that implements it has not yet been loaded and linked into the Java Virtual Machine, that is done. The <i>nargs </i>- 1 words of arguments and <i>objectref</i> are popped from the operand stack; the code that implements the method is invoked in an implementation-dependent manner.<p>
<a name="invokespecial.Linking"></a>
<b>Linking Exceptions</h3></b>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -