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

📄 instructions2.doc7.html

📁 Jvm 规范说明。The Java Virtual Machine was designed to support the Java programming language. Some concep
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<a name="158759"></a>
During resolution of the <code>CONSTANT_Methodref </code>constant pool item, any of the exceptions documented in <a href="ConstantPool.doc.html#49425">&#167;5.2</a> can be thrown.<p>
<a name="68877"></a>
Otherwise, if the specified method exists but is a class (<code>static</code>) method, the <i>invokespecial</i> instruction throws an <code>IncompatibleClassChangeError</code>.<p>
<a name="68878"></a>
Otherwise, if the specified method is <code>abstract</code>, <i>invokespecial</i> throws an <code>AbstractMethodError</code>.<p>
<a name="68879"></a>
Otherwise, if the specified method is <code>native</code> and the code that implements the method cannot be loaded or linked, <i>invokespecial</i> throws an <code>UnsatisfiedLinkError</code>.<p>
<a name="invokespecial.Runtime"></a>
<b>Runtime Exception</h3></b>
<a name="68881"></a>
Otherwise, if <i>objectref</i> is <code>null</code>, the <i>invokespecial</i> instruction throws a <code>NullPointerException</code>. <p>

<b>Notes</h3></b>
<a name="68888"></a>
The difference between the <i>invokespecial</i> and the <i>invokevirtual</i> instructions is that <i>invokevirtual</i> invokes a method based on the class of the object. The <i>invokespecial</i> instruction is used to invoke instance initialization methods (<code>&lt;init&gt;</code>) as well as <code>private</code> methods and methods of a superclass of the current class. <p>
<a name="68890"></a>
The <i>invokespecial</i> instruction was named <i>invokenonvirtual</i> prior to Sun's JDK 1.0.2 release.<p>

<a name="invokestatic"></a>
<hr><h2>invokestatic</h2>
<a name="invokestatic.Operation"></a>
<b>Operation</h3></b>
<a name="68901"></a>
Invoke a class (<code>static</code>) method<p><Table Border="1">
<tr><td><a name="68896"></a>
 <i>invokestatic</i>
<td><a name="87568"></a>
 

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

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

</Table><br><br><p>
<a name="invokestatic.Forms"></a>
<b>Forms</h3></b>
<a name="68902"></a>
<i>invokestatic</i> = 184 (0xb8)<p>
<a name="invokestatic.Stack"></a>
<b>Stack</h3></b>
<a name="68903"></a>
...<em>, [</em><i>arg1</i><em>, [</em><i>arg2</i><em> </em>...<em>]] </em><img src="chars/arrwdbrt.gif"> ...<p>
<a name="invokestatic.Description"></a>
<b>Description</h3></b>
<a name="68904"></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">(&#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 have the tag <code>CONSTANT_Methodref</code> <a href="ClassFile.doc.html#4723">(&#167;4.4.2)</a>, a reference to a class name, a method name, and the method's descriptor <a href="ClassFile.doc.html#7035">(&#167;4.3.3)</a>. The named method is resolved <a href="ConstantPool.doc.html#49425">(&#167;5.2)</a>. The descriptor of the resolved method must be identical to the descriptor of one of the methods of the resolved class. The method must not be <code>&lt;init&gt;</code>, an instance initialization method <a href="Overview.doc.html#12174">(&#167;3.8)</a>, or <code>&lt;clinit&gt;</code>, a class or interface initialization method <a href="Overview.doc.html#12174">(&#167;3.8)</a>. It must be <code>static</code>, and therefore cannot be <code>abstract</code>. Finally, if the method is <code>protected</code> <a href="ClassFile.doc.html#1513">(&#167;4.6)</a>, then it must be either a member of the current class or a member of a superclass of the current class.<p>
<a name="68920"></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 may 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>
The operand stack must contain <i>nargs</i> 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 resolved method.<p>
<a name="138176"></a>
If the method is <code>synchronized</code>, the monitor associated with the current class is acquired.<p>
<a name="138172"></a>
If the method is not <code>native</code>, the <i>nargs </i>words of arguments are popped from the operand stack. A new stack frame is created for the method being invoked, and the words of arguments are made the values of its first <i>nargs</i> local variables, with <i>arg1</i> in local variable <i>0</i>, <i>arg2</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="138173"></a>
If the method is <code>native</code>, the <i>nargs </i>words of arguments are popped from the operand stack; the code that implements the method is invoked in an implementation-dependent manner.<p>
<a name="invokestatic.Linking"></a>
<b>Linking Exceptions</h3></b>
<a name="117162"></a>
During resolution of the <code>CONSTANT_Methodref </code>constant pool item, any of the exceptions documented in <a href="ConstantPool.doc.html#49425">&#167;5.2</a> can be thrown.<p>
<a name="68925"></a>
Otherwise, if the specified method exists but is an instance method, the <i>invokestatic</i> instruction throws an <code>IncompatibleClass-ChangeError</code>.<p>
<a name="158805"></a>
Otherwise, if the specified method is <code>native</code> and the code that implements the method cannot be loaded or linked, <i>invokestatic</i> throws an <code>UnsatisfiedLinkError</code>.<p>

<a name="invokevirtual"></a>
<hr><h2>invokevirtual</h2>
<a name="invokevirtual.Operation"></a>
<b>Operation</h3></b>
<a name="68948"></a>
Invoke instance method<p><Table Border="1">
<tr><td><a name="68943"></a>
 <i>invokevirtual</i>
<td><a name="87568"></a>
 

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

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

</Table><br><br>; dispatch based on class<p>
<a name="invokevirtual.Forms"></a>
<b>Forms</h3></b>
<a name="68949"></a>
<i>invokevirtual</i> = 182 (0xb6)<p>
<a name="invokevirtual.Stack"></a>
<b>Stack</h3></b>
<a name="68950"></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="invokevirtual.Description"></a>
<b>Description</h3></b>
<a name="68951"></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">(&#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 have the tag <code>CONSTANT_Methodref</code> <a href="ClassFile.doc.html#4723">(&#167;4.4.2)</a>, a reference to a class name, a method name, and the method's descriptor <a href="ClassFile.doc.html#7035">(&#167;4.3.3)</a>. The named method is resolved <a href="ConstantPool.doc.html#49425">(&#167;5.2)</a>. The descriptor of the resolved method must be identical to the descriptor of the one of the methods of the resolved class. The method must not be <code>&lt;init&gt;</code>, an instance initialization method <a href="Overview.doc.html#12174">(&#167;3.8)</a>, or <code>&lt;clinit&gt;</code>, a class or interface initialization method <a href="Overview.doc.html#12174">(&#167;3.8)</a>. Finally, if the method is <code>protected</code> <a href="ClassFile.doc.html#1513">(&#167;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="68967"></a>
The constant pool entry representing the resolved method includes an unsigned <i>index</i> into the method table of the resolved class and an unsigned byte <i>nargs</i> that must not be zero.<p>
The <i>objectref</i> must be of type <code>reference</code>. The <i>index</i> is used as an index into the method table of the class of the type of <i>objectref</i>. If the <i>objectref</i> is an array type, then the method table of class <code>Object</code> is used. The table entry at that index includes a direct reference to the method's code and its modifier information (see <a href="ClassFile.doc.html#12725">Table 4.4, "Method access and modifier flags"</a>).<p>
<a name="68969"></a>
The <i>objectref</i> 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="138096"></a>
If the method is <code>synchronized</code>, the monitor associated with <i>objectref</i> is acquired.<p>
<a name="135976"></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="138113"></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="invokevirtual.Linking"></a>
<b>Linking Exceptions</h3></b>
<a name="117277"></a>
During resolution of the <code>CONSTANT_Methodref</code> constant pool item, any of the exceptions documented in <a href="ConstantPool.doc.html#49425">&#167;5.2</a> can be thrown.<p>
Otherwise, if the specified method exists but is a class (<code>static</code>) method, the <i>invokevirtual</i> instruction throws an <code>Incompatible-Class-ChangeError</code>.<p>
<a name="68974"></a>
Otherwise, if the specified method is <code>abstract</code>, <i>invokevirtual</i> throws an <code>AbstractMethodError</code>.<p>
<a name="68975"></a>
Otherwise, if the specified method is <code>native</code> and the code that implements the method cannot be loaded or linked, <i>invokevirtual</i> throws an <code>UnsatisfiedLinkError</code>.<p>
<a name="invokevirtual.Runtime"></a>
<b>Runtime Exception</h3></b>
<a name="68977"></a>
Otherwise, if <i>objectref</i> is <code>null</code>, the <i>invokevirtual</i> instruction throws a <code>NullPointerException</code>. <p>

<a name="ior"></a>
<hr><h2>ior</h2>
<a name="ior.Operation"></a>
<b>Operation</h3></b>
<a name="68994"></a>
Boolean OR <code>int</code><p><Table Border="1">
<tr><td><a name="68993"></a>
 <i>ior</i>
<td><a name="87568"></a>
 

</Table><br><br><p>
<a name="ior.Forms"></a>
<b>Forms</h3></b>
<a name="68995"></a>
<i>ior</i> = 128 (0x80)<p>
<a name="ior.Stack"></a>
<b>Stack</h3></b>
<a name="68996"></a>
..., <i>value1</i><em>, </em><i>value2</i> <img src="chars/arrwdbrt.gif"> ..., <i>result</i><p>
<a name="ior.Description"></a>
<b>Description</h3></b>
<a name="68997"></a>
Both<i> value1</i> and <i>value2</i> must both be of type <code>int</code>. They are popped from the operand stack. An <code>int</code> <i>result</i> is calculated by taking the bitwise inclusive OR of <i>value1</i> and <i>value2</i>. The <i>result</i> is pushed onto the operand stack.<p>

<a name="irem"></a>
<hr><h2>irem</h2>
<a name="irem.Operation"></a>
<b>Operation</h3></b>
<a name="69007"></a>
Remainder <code>int</code><p><Table Border="1">
<tr><td><a name="69006"></a>
 <i>irem</i>
<td><a name="87568"></a>
 

</Table><br><br><p>
<a name="irem.Forms"></a>
<b>Forms</h3></b>
<a name="69008"></a>
<i>irem</i> = 112 (0x70)<p>
<a name="irem.Stack"></a>
<b>Stack</h3></b>
<a name="69009"></a>
..., <i>value1</i><em>, </em><i>value2</i> <img src="chars/arrwdbrt.gif"> ..., <i>result</i><p>
<a name="irem.Description"></a>
<b>Description</h3></b>
<a name="69010"></a>
Both <i>value1</i> and <i>value2</i> must be of type <code>int</code>. The values are popped from the operand stack. The <code>int</code> <i>result</i> is <i>value1</i> - (<i>value1</i> / <i>value2</i>) * <i>value2</i>. The <i>result</i> is pushed onto the operand stack.<p>
<a name="69011"></a>
The result of the <i>irem</i> instruction is such that <code>(a/b)*b</code> <code>+</code> <code>(a%b)</code> is equal to <code>a</code>. This identity holds even in the special case that the dividend is the negative <code>int</code> of largest possible magnitude for its type and the divisor is -<code>1</code> (the remainder is <code>0</code>). It follows from this rule that the result of the remainder operation can be negative only if the dividend is negative and can be positive only if the dividend is positive. Moreover, the magnitude of the result is always less than the magnitude of the divisor. <p>
<a name="irem.Runtime"></a>
<b>Runtime Exception</h3></b>
<a name="69013"></a>
If the value of the divisor for an <code>int</code> remainder operator is 0, <i>irem</i> throws an <code>ArithmeticException</code>.<p>
<a name="69014"></a>
<p>

<a name="ireturn"></a>
<hr><h2>ireturn</h2>
<a name="ireturn.Operation"></a>
<b>Operation</h3></b>
<a name="69024"></a>
Return <code>int</code> from method<p><Table Border="1">
<tr><td><a name="69023"></a>
 <i>ireturn</i>
<td><a name="87568"></a>
 

</Table><br><br><p>
<a name="ireturn.Forms"></a>
<b>Forms</h3></b>
<a name="69025"></a>
<i>ireturn</i> = 172 (0xac)<p>
<a name="ireturn.Stack"></a>
<b>Stack</h3></b>
<a name="69026"></a>
..., <i>value</i><em> </em><img src="chars/arrwdbrt.gif"> <p>
<a name="178030"></a>
[empty]<p>
<a name="ireturn.Description"></a>
<b>Description</h3></b>
<a name="69027"></a>
The returning method must have return type <code>byte</code>, <code>short</code>, <code>char</code>, or <code>int</code>. The <i>value</i> must be of type <code>int</code>. The <i>value</i> is popped from the operand stack of the current frame <a href="Overview.doc.html#17257">(&#167;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. If the returning method is a <code>synchronized</code> method, the monitor acquired or re-entered on invocation of the method is released or exited (respectively) as if by execution of a <i>monitorexit</i> instruction. <p>
<a name="69031"></a>
The interpreter then returns control to the invoker of the method, reinstating the frame of the invoker.<p>

<a name="ishl"></a>
<hr><h2>ishl</h2>
<a name="ishl.Operation"></a>
<b>Operation</h3></b>
<a name="69041"></a>
Shift left <code>int</code><p><Table Border="1">
<tr><td><a name="69040"></a>
 <i>ishl</i>
<td><a name="87568"></a>
 

</Table><br><br><p>
<a name="ishl.Forms"></a>
<b>Forms</h3></b>
<a name="69042"></a>
<i>ishl</i> = 120 (0x78)<p>
<a name="ishl.Stack"></a>
<b>Stack</h3></b>
<a name="69043"></a>
..., <i>value1</i><em>, </em><i>value2</i> <img src="chars/arrwdbrt.gif"> ..., <i>result</i><p>
<a name="ishl.Description"></a>
<b>Description</h3></b>
<a name="69044"></a>
Both <i>value1</i> and <i>value2</i> must be of type <code>int</code>. The values are popped from the operand stack. An <code>int</code> <i>result</i> is calculated by shifting <i>value1</i> left by <em>s</em> bit positions, where <em>s</em> is the value of the low five bits of <i>value2</i>. The <i>result</i> is pushed onto the operand stack.<p>
<a name="ishl.Notes"></a>
<b>Notes</h3></b>
<a name="69045"></a>
This is equivalent (even if overflow occurs) to multiplication by 2 to the power <em>s</em>. The shift distance actually used is always in the range 0 to 31, inclusive, as if <i>value2</i> were subjected to a bitwise logical AND with the mask value 0x1f. <p>

<a name="ishr"></a>
<hr><h2>ishr</h2>
<a name="ishr.Operation"></a>
<b>Operation</h3></b>
<a name="69055"></a>
Arithmetic shift right <co

⌨️ 快捷键说明

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