Contents | Prev | Next | IndexThe JavaTM Virtual Machine Specification


i2b

Operation Convert int to byte

i2b


Forms i2b = 145 (0x91)

Stack ..., value ..., result

Description The value on the top of the operand stack must be of type int. It is popped from the operand stack, truncated to a byte, then sign-extended to an int result. The result is pushed onto the operand stack.

Notes The i2b instruction performs a narrowing primitive conversion (§2.6.3). It may lose information about the overall magnitude of value. The result may also not have the same sign as value.


i2c

Operation Convert

i2c


int to char

Forms i2c = 146 (0x92)

Stack ..., value ..., result

Description The value on the top of the operand stack must be of type int. It is popped from the operand stack, truncated to char, then zero-extended to an int result. The result is pushed onto the operand stack.

Notes The i2c instruction performs a narrowing primitive conversion (§2.6.3). It may lose information about the overall magnitude of value. The result (which is always positive) may also not have the same sign as value.


i2d

Operation Convert int to double

i2d


Forms i2d = 135 (0x87)

Stack ..., value ..., result.word1, result.word2

Description The value on the top of the operand stack must be of type int. It is popped from the operand stack and converted to a double result. The result is pushed onto the operand stack.

Notes The i2d instruction performs a widening primitive conversion (§2.6.2). Because all values of type int are exactly representable by type double, the conversion is exact.


i2f

Operation Convert int to float

i2f


Forms i2f = 134 (0x86)

Stack ..., value ..., result

Description The value on the top of the operand stack must be of type int. It is popped from the operand stack and converted to the float result using IEEE 754 round-to-nearest mode. The result is pushed onto the operand stack.

Notes The i2f instruction performs a widening primitive conversion (§2.6.2), but may result in a loss of precision because type float has only 24 mantissa bits.


i2l

Operation Convert int to long

i2l


Forms i2l = 133 (0x85)

Stack ..., value ..., result.word1, result.word2

Description The value on the top of the operand stack must be of type int. It is popped from the operand stack and sign-extended to a long result. The result is pushed onto the operand stack.

Notes The i2l instruction performs a widening primitive conversion (§2.6.2). Because all values of type int are exactly representable by type long, the conversion is exact.


i2s

Operation

i2s


Convert int to short

Forms i2s = 147 (0x93)

Stack ..., value ..., result

Description The value on the top of the operand stack must be of type int. It is popped from the operand stack, truncated to a short, then sign-extended to an int result. The result is pushed onto the operand stack.

Notes The i2s instruction performs a narrowing primitive conversion (§2.6.3). It may lose information about the overall magnitude of value. The result may also not have the same sign as value.


iadd

Operation Add int

iadd


Forms iadd = 96 (0x60)

Stack ..., value1, value2 ..., result

Description Both value1 and value2 must be of type int. The values are popped from the operand stack. The int result is value1 + value2. The result is pushed onto the operand stack.

If an iadd overflows, then the result is the low-order bits of the true mathematical result in a sufficiently wide two's-complement format. If overflow occurs, then the sign of the result will not be the same as the sign of the mathematical sum of the two values.


iaload

Operation Load int from array

iaload


Forms iaload = 46 (0x2e)

Stack ..., arrayref, index ..., value

Description The arrayref must be of type reference and must refer to an array whose components are of type int. The index must be of type int. Both arrayref and index are popped from the operand stack. The int value in the component of the array at index is retrieved and pushed onto the top of the operand stack.

Runtime Exceptions If arrayref is null, iaload throws a NullPointerException.

Otherwise, if index is not within the bounds of the array referenced by arrayref, the iaload instruction throws an ArrayIndexOutOfBoundsException.


iand

Operation Boolean AND int

iand


Forms iand = 126 (0x7e)

Stack ..., value1, value2 ..., result

Description Both value1 and value2 must be of type int. They are popped from the operand stack. An int result is calculated by taking the bitwise AND (conjunction) of value1 and value2. The result is pushed onto the operand stack.


iastore

Operation Store into int array

iastore


Forms iastore = 79 (0x4f)

Stack ..., arrayref, index, value ...

Description The arrayref must be of type reference and must refer to an array whose components are of type int. Both index and value must be of type int. The arrayref, index, and value are popped from the operand stack. The int value is stored as the component of the array indexed by index.

Runtime Exceptions If arrayref is null, iastore throws a NullPointerException.

Otherwise, if index is not within the bounds of the array referenced by arrayref, the iastore instruction throws an ArrayIndexOutOfBoundsException.


iconst_<i>

Operation Push int constant

iconst_<i>


Forms iconst_m1 = 2 (0x2)

iconst_0 = 3 (0x3)

iconst_1 = 4 (0x4)

iconst_2 = 5 (0x5)

iconst_3 = 6 (0x6)

iconst_4 = 7 (0x7)

iconst_5 = 8 (0x8)

Stack ... ..., <i>

Description Push the int constant <i> (-1, 0, 1, 2, 3, 4 or 5) onto the operand stack.

Notes Each of this family of instructions is equivalent to bipush <i> for the respective value of <i>, except that the operand <i> is implicit.


idiv

Operation Divide int

idiv


Forms idiv = 108 (0x6c)

Stack ..., value1, value2 ..., result

Description Both value1 and value2 must be of type int. The values are popped from the operand stack. The int result is the value of the Java expression value1 / value2. The result is pushed onto the operand stack.

An int division rounds towards 0; that is, the quotient produced for int values in n/d is an int value q whose magnitude is as large as possible while satisfying



. Moreover, q is positive when



and n and d have the same sign, but q is negative when



and n and d have opposite signs.

There is one special case that does not satisfy this rule: if the dividend is the negative integer of largest possible magnitude for the int type, and the divisor is -1, then overflow occurs, and the result is equal to the dividend. Despite the overflow, no exception is thrown in this case.

Runtime Exception If the value of the divisor in an int division is 0, idiv throws an ArithmeticException.


if_acmp<cond>

Operation Branch if reference comparison succeeds

if_acmp<cond>
branchbyte1
branchbyte2


Forms if_acmpeq = 165 (0xa5)

if_acmpne = 166 (0xa6)

Stack ..., value1, value2 ...

Description Both value1 and value2 must be of type reference. They are both popped from the operand stack and compared. The results of the comparison are as follows:

If the comparison succeeds, the unsigned branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset, where the offset is calculated to be (branchbyte1 << 8) | branchbyte2. Execution then proceeds at that offset from the address of the opcode of this if_acmp<cond> instruction. The target address must be that of an opcode of an instruction within the method that contains this if_acmp<cond> instruction.

Otherwise, if the comparison fails, execution proceeds at the address of the instruction following this if_acmp<cond> instruction.


if_icmp<cond>

Operation Branch if int comparison succeeds

if_icmp<cond>
branchbyte1
branchbyte2


Forms if_icmpeq = 159 (0x9f)

if_icmpne = 160 (0xa0)

if_icmplt = 161 (0xa1)

if_icmpge = 162 (0xa2)

if_icmpgt = 163 (0xa3)

if_icmple = 164 (0xa4)

Stack ..., value1, value2 ...

Description Both value1 and value2 must be of type int. They are both popped from the operand stack and compared. All comparisons are signed. The results of the comparison are as follows:

If the comparison succeeds, the unsigned branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset, where the offset is calculated to be (branchbyte1 << 8) | branchbyte2. Execution then proceeds at that offset from the address of the opcode of this if_icmp<cond> instruction. The target address must be that of an opcode of an instruction within the method that contains this if_icmp<cond> instruction.

Otherwise, execution proceeds at the address of the instruction following this if_icmp<cond> instruction.


if<cond>

Operation Branch if int comparison with zero succeeds

if<cond>
branchbyte1
branchbyte2


Forms ifeq = 153 (0x99)

ifne = 154 (0x9a)

iflt = 155 (0x9b)

ifge = 156 (0x9c)

ifgt = 157 (0x9d)

ifle = 158 (0x9e)

Stack ..., value ...

Description The value must be of type int. It is popped from the operand stack and compared against zero. All comparisons are signed. The results of the comparisons are as follows:

If the comparison succeeds, the unsigned branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset, where the offset is calculated to be (branchbyte1 << 8) | branchbyte2. Execution then proceeds at that offset from the address of the opcode of this if<cond> instruction. The target address must be that of an opcode of an instruction within the method that contains this if<cond> instruction.

Otherwise, execution proceeds at the address of the instruction following this if<cond> instruction.


ifnonnull

Operation Branch if reference not null

ifnonnull
branchbyte1
branchbyte2


Forms ifnonnull = 199 (0xc7)

Stack ..., value ...

Description The value must of type reference. It is popped from the oper-and stack. If value is not null, the unsigned branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset, where the offset is calculated to be (branchbyte1 << 8) | branchbyte2. Execution then proceeds at that offset from the address of the opcode of this ifnonnull instruction. The target address must be that of an opcode of an instruction within the method that contains this ifnonnull instruction.

Otherwise, execution proceeds at the address of the instruction following this ifnonnull instruction.


ifnull

Operation Branch if reference is null

ifnull
branchbyte1
branchbyte2


Forms ifnull = 198 (0xc6)

Stack ..., value ...

Description The value must of type reference. It is popped from the operand stack. If value is null, the unsigned branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset, where the offset is calculated to be (branchbyte1 << 8) | branchbyte2. Execution then proceeds at that offset from the address of the opcode of this ifnull instruction. The target address must be that of an opcode of an instruction within the method that contains this ifnull instruction.

Otherwise, execution proceeds at the address of the instruction following this ifnull instruction.


iinc

Operation Increment local variable by constant

iinc
index
const


Forms iinc = 132 (0x84)

Stack No change

Description The index is an unsigned byte that must be a valid index into the local variables of the current frame (§3.6). The const is a immediate signed byte. The local variable at index must contain an int. The value const is first sign-extended to an int, then the local variable at index is incremented by that amount.

Notes The iinc opcode can be used in conjunction with the wide instruction to access a local variable using a two-byte unsigned index and increment it by a two-byte immediate value.


iload

Operation Load int from local variable

iload
index


Forms iload = 21 (0x15)

Stack ... ..., value

Description The index is an unsigned byte that must be a valid index into the local variables of the current frame (§3.6). The local variable at index must contain an int. The value of the local variable at index is pushed onto the operand stack.

Notes The iload opcode can be used in conjunction with the wide instruction to access a local variable using a two-byte unsigned index.


iload_<n>

Operation Load int from local variable

iload_<n>


Forms iload_0 = 26 (0x1a)

iload_1 = 27 (0x1b)

iload_2 = 28 (0x1c)

iload_3 = 29 (0x1d)

Stack ... ..., value

Description The <n> must be a valid index into the local variables of the current frame (§3.6). The local variable at <n> must contain an int. The value of the local variable at <n> is pushed onto the operand stack.

Notes Each of the iload_<n> instructions is the same as iload with an index of <n>, except that the operand <n> is implicit.


imul

Operation Multiply int

imul


Forms imul = 104 (0x68)

Stack ..., value1, value2 ..., result

Description Both value1 and value2 must be of type int. The values are popped from the operand stack. The int result is value1 * value2. The result is pushed onto the operand stack.

If an int multiplication overflows, then the result is the low-order bits of the mathematical product as an int. If overflow occurs, then the sign of the result may not be the same as the sign of the mathematical product of the two values.


ineg

Operation Negate int

ineg


Forms ineg = 116 (0x74)

Stack ..., value ..., result

Description The value must be of type int. It is popped from the operand stack. The int result is the arithmetic negation of value, -value. The result is pushed onto the operand stack.

For int 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 int results in that same maximum negative number. Despite the fact that overflow has occurred, no exception is thrown.

For all int values x, -x equals (~x) + 1.


instanceof

Operation

instanceof
indexbyte1
indexbyte2


Determine if object is of given type

Forms instanceof = 193 (0xc1)

Stack ..., objectref ..., result

Description The objectref, which must be of type reference, is popped from the operand stack. The unsigned indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The item at that index in the constant pool must be a CONSTANT_Class (§4.4.1), a symbolic reference to a class, array, or interface. The symbolic reference is resolved (§5.1).

If objectref is not null and is an instance of the resolved class, array, or interface, the instanceof instruction pushes an int result of 1 as an int on the operand stack. Otherwise, it pushes an int result of 0.

The following rules are used to determine whether an objectref that is not null is an instance of the resolved type: If S is the class of the object referred to by objectref and T is the resolved class, array, or interface type, instanceof determines whether objectref is an instance of T as follows:


instanceof

S cannot be an interface type, because there are no instances of interfaces, only instances of classes and arrays.

Linking Exceptions During resolution of the CONSTANT_Class constant pool item, any of the exceptions documented in §5.1 can be thrown.

Notes The instanceof instruction is fundamentally very similar to the checkcast instruction. It differs in its treatment of null, its behavior when its test fails (checkcast throws an exception, instanceof pushes a result code), and its effect on the operand stack.


invokeinterface

Operation Invoke interface method

invokeinterface
indexbyte1
indexbyte2
nargs
0


Forms invokeinterface = 185 (0xb9)

Stack ..., objectref, [arg1, [arg2 ...]] ...

Description The unsigned indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The item at that index in the constant pool must have the tag CONSTANT_InterfaceMethodref (§4.4.2), a reference to an interface name, a method name, and the method's descriptor (§4.3.3). The constant pool item is resolved (§5.3). The interface method must not be <init>, an instance initialization method (§3.8), or <clinit>, a class or interface initialization method (§3.8).

The nargs operand is an unsigned byte which must not be zero. The objectref must be of type reference and must be followed on the operands stack by nargs - 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.

The method table of the class of the type of objectref is determined. If objectref is an array type, then the method table of class Object 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.

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 Table 4.4, "Method access and modifier flags"). The method table entry must be that of a public method.

If the method is synchronized, the monitor associated with objectref is acquired.

If the method is not native, the nargs - 1 words of arguments and objectref are popped from the operand stack. A new stack frame is created for the method being invoked, and objectref and the words of arguments are made the values of its first nargs local variables, with objectref in local variable 0, arg1 in local variable 1, and so on. The new stack frame is then made current, and the Java Virtual Machine pc is set to the opcode of the first instruction of the method to be invoked. Execution continues with the first instruction of the method.

If the method is native and the platform-dependent code that implements it has not yet been loaded and linked into the Java Virtual Machine, that is done. The nargs - 1 words of arguments and objectref are popped from the operand stack; the code that implements the method is invoked in an implementation-dependent manner.

Linking Exceptions During resolution of the CONSTANT_InterfaceMethodref constant pool item, any of the exceptions documented in §5.3 can be thrown.

Otherwise, if no method matching the resolved name and descriptor can be found in the class of objectref, invokeinterface throws an IncompatibleClassChangeError.

Otherwise, if the selected method is a class (static) method, the invokeinterface instruction throws an IncompatibleClass-ChangeError.


invokeinterface

Otherwise, if the selected method is not public, invokeinterface throws an IllegalAccessError.

Otherwise, if the selected method is abstract, invokeinterface throws an AbstractMethodError.

Otherwise, if the selected method is native and the code that implements the method cannot be loaded or linked, invokeinterface throws an UnsatisfiedLinkError.

Runtime Exception Otherwise, if objectref is null, the invokeinterface instruction throws a NullPointerException.

Notes Unlike invokevirtual, invokestatic, and invokespecial, the number of arguments words (nargs) for the method invocation is made available as an operand of the invokeinterface 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 nargs operand. This redundancy is historical, but the nargs operand also reserves space in the instruction for an operand used by the invokeinterface_quick pseudo-instruction which may replace invokeinterface at run time. See Chapter 9, "An Optimization," for information on invokeinterface_quick.

The fourth operand byte of the invokeinterface instruction is unused by the instruction itself and must be zero. It exists only to reserve space for an additional operand added if the invokeinterface instruction is replaced by the invokeinterface_quick pseudo-instruction at run time.


invokespecial

Operation Invoke instance method; special handling for superclass, private, and instance initialization method invocations

invokespecial
indexbyte1
indexbyte2


Forms invokespecial = 183 (0xb7)

Stack ..., objectref, [arg1, [arg2 ...]] ...

Description The unsigned indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The item at that index in the constant pool must have the tag CONSTANT_Methodref (§4.4.2), a reference to a class name, a method name, and the method's descriptor (§4.3.3). The named method is resolved (§5.2). The descriptor of the resolved method must be identical to the descriptor of one of the methods of the resolved class.

Next, the Java Virtual Machine determines if all of the following conditions are true:

If so, then the Java Virtual Machine selects the method with the identical descriptor in the closest superclass, possibly selecting the method just resolved.

The resulting method must not be <clinit>, a class or interface initialization method (§3.8).

If the method is <init>, an instance initialization method (§3.8), then the method must only be invoked once on an uninitialized object, and before the first backward branch following the execution of the new instruction that allocated the object.

Finally, if the method is protected (§4.6), 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 objectref must be either the current class or a subclass of the current class.

The constant pool entry representing the resolved method includes a direct reference to the code for the method, an unsigned byte nargs that must not be zero, and the method's modifier information (see Table 4.4, "Method access and modifier flags").

The objectref must be of type reference and must be followed on the operand stack by nargs - 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.

If the method is synchronized, the monitor associated with objectref is acquired.

If the method is not native, the nargs - 1 words of arguments and objectref are popped from the operand stack. A new stack frame is created for the method being invoked, and objectref and the words of arguments are made the values of its first nargs local variables, with objectref in local variable 0, arg1 in local variable 1, and so on. The new stack frame is then made current, and the Java Virtual Machine pc is set to the opcode of the first instruction of the method to be invoked. Execution continues with the first instruction of the method.

If the method is native and the platform-dependent code that implements it has not yet been loaded and linked into the Java Virtual Machine, that is done. The nargs - 1 words of arguments and objectref are popped from the operand stack; the code that implements the method is invoked in an implementation-dependent manner.

Linking Exceptions During resolution of the CONSTANT_Methodref constant pool item, any of the exceptions documented in §5.2 can be thrown.

Otherwise, if the specified method exists but is a class (static) method, the invokespecial instruction throws an IncompatibleClassChangeError.

Otherwise, if the specified method is abstract, invokespecial throws an AbstractMethodError.

Otherwise, if the specified method is native and the code that implements the method cannot be loaded or linked, invokespecial throws an UnsatisfiedLinkError.

Runtime Exception Otherwise, if objectref is null, the invokespecial instruction throws a NullPointerException.

Notes The difference between the invokespecial and the invokevirtual instructions is that invokevirtual invokes a method based on the class of the object. The invokespecial instruction is used to invoke instance initialization methods (<init>) as well as private methods and methods of a superclass of the current class.

The invokespecial instruction was named invokenonvirtual prior to Sun's JDK 1.0.2 release.


invokestatic

Operation Invoke a class (static) method

invokestatic
indexbyte1
indexbyte2


Forms invokestatic = 184 (0xb8)

Stack ..., [arg1, [arg2 ...]] ...

Description The unsigned indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The item at that index in the constant pool must have the tag CONSTANT_Methodref (§4.4.2), a reference to a class name, a method name, and the method's descriptor (§4.3.3). The named method is resolved (§5.2). 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 <init>, an instance initialization method (§3.8), or <clinit>, a class or interface initialization method (§3.8). It must be static, and therefore cannot be abstract. Finally, if the method is protected (§4.6), then it must be either a member of the current class or a member of a superclass of the current class.

The constant pool entry representing the resolved method includes a direct reference to the code for the method, an unsigned byte nargs that may be zero, and the method's modifier information (see Table 4.4, "Method access and modifier flags").

The operand stack must contain nargs 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.

If the method is synchronized, the monitor associated with the current class is acquired.

If the method is not native, the nargs 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 nargs local variables, with arg1 in local variable 0, arg2 in local variable 1, and so on. The new stack frame is then made current, and the Java Virtual Machine pc is set to the opcode of the first instruction of the method to be invoked. Execution continues with the first instruction of the method.

If the method is native, the nargs words of arguments are popped from the operand stack; the code that implements the method is invoked in an implementation-dependent manner.

Linking Exceptions During resolution of the CONSTANT_Methodref constant pool item, any of the exceptions documented in §5.2 can be thrown.

Otherwise, if the specified method exists but is an instance method, the invokestatic instruction throws an IncompatibleClass-ChangeError.

Otherwise, if the specified method is native and the code that implements the method cannot be loaded or linked, invokestatic throws an UnsatisfiedLinkError.


invokevirtual

Operation Invoke instance method

invokevirtual
indexbyte1
indexbyte2


; dispatch based on class

Forms invokevirtual = 182 (0xb6)

Stack ..., objectref, [arg1, [arg2 ...]] ...

Description The unsigned indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The item at that index in the constant pool must have the tag CONSTANT_Methodref (§4.4.2), a reference to a class name, a method name, and the method's descriptor (§4.3.3). The named method is resolved (§5.2). 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 <init>, an instance initialization method (§3.8), or <clinit>, a class or interface initialization method (§3.8). Finally, if the method is protected (§4.6), 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 objectref must be either the current class or a subclass of the current class.

The constant pool entry representing the resolved method includes an unsigned index into the method table of the resolved class and an unsigned byte nargs that must not be zero.

The objectref must be of type reference. The index is used as an index into the method table of the class of the type of objectref. If the objectref is an array type, then the method table of class Object is used. The table entry at that index includes a direct reference to the method's code and its modifier information (see Table 4.4, "Method access and modifier flags").

The objectref must be followed on the operand stack by nargs - 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.

If the method is synchronized, the monitor associated with objectref is acquired.

If the method is not native, the nargs - 1 words of arguments and objectref are popped from the operand stack. A new stack frame is created for the method being invoked, and objectref and the words of arguments are made the values of its first nargs local variables, with objectref in local variable 0, arg1 in local variable 1, and so on. The new stack frame is then made current, and the Java Virtual Machine pc is set to the opcode of the first instruction of the method to be invoked. Execution continues with the first instruction of the method.

If the method is native and the platform-dependent code that implements it has not yet been loaded and linked into the Java Virtual Machine, that is done. The nargs - 1 words of arguments and objectref are popped from the operand stack; the code that implements the method is invoked in an implementation-dependent manner.

Linking Exceptions During resolution of the CONSTANT_Methodref constant pool item, any of the exceptions documented in §5.2 can be thrown.

Otherwise, if the specified method exists but is a class (static) method, the invokevirtual instruction throws an Incompatible-Class-ChangeError.

Otherwise, if the specified method is abstract, invokevirtual throws an AbstractMethodError.

Otherwise, if the specified method is native and the code that implements the method cannot be loaded or linked, invokevirtual throws an UnsatisfiedLinkError.

Runtime Exception Otherwise, if objectref is null, the invokevirtual instruction throws a NullPointerException.


ior

Operation Boolean OR int

ior


Forms ior = 128 (0x80)

Stack ..., value1, value2 ..., result

Description Both value1 and value2 must both be of type int. They are popped from the operand stack. An int result is calculated by taking the bitwise inclusive OR of value1 and value2. The result is pushed onto the operand stack.


irem

Operation Remainder int

irem


Forms irem = 112 (0x70)

Stack ..., value1, value2 ..., result

Description Both value1 and value2 must be of type int. The values are popped from the operand stack. The int result is value1 - (value1 / value2) * value2. The result is pushed onto the operand stack.

The result of the irem instruction is such that (a/b)*b + (a%b) is equal to a. This identity holds even in the special case that the dividend is the negative int of largest possible magnitude for its type and the divisor is -1 (the remainder is 0). 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.

Runtime Exception If the value of the divisor for an int remainder operator is 0, irem throws an ArithmeticException.


ireturn

Operation Return int from method

ireturn


Forms ireturn = 172 (0xac)

Stack ..., value

[empty]

Description The returning method must have return type byte, short, char, or int. The value must be of type int. The value is popped from the operand stack of the current frame (§3.6) 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 synchronized method, the monitor acquired or re-entered on invocation of the method is released or exited (respectively) as if by execution of a monitorexit instruction.

The interpreter then returns control to the invoker of the method, reinstating the frame of the invoker.


ishl

Operation Shift left int

ishl


Forms ishl = 120 (0x78)

Stack ..., value1, value2 ..., result

Description Both value1 and value2 must be of type int. The values are popped from the operand stack. An int result is calculated by shifting value1 left by s bit positions, where s is the value of the low five bits of value2. The result is pushed onto the operand stack.

Notes This is equivalent (even if overflow occurs) to multiplication by 2 to the power s. The shift distance actually used is always in the range 0 to 31, inclusive, as if value2 were subjected to a bitwise logical AND with the mask value 0x1f.


ishr

Operation Arithmetic shift right int

ishr


Forms ishr = 122 (0x7a)

Stack ..., value1, value2 ..., result

Description Both value1 and value2 must be of type int. The values are popped from the operand stack. An int result is calculated by shifting value1 right by s bit positions, with sign extension, where s is the value of the low five bits of value2. The result is pushed onto the operand stack.

Notes The resulting value is



, where s is value2 & 0x1f. For nonnegative value1, this is equivalent to truncating int division by 2 to the power s. The shift distance actually used is always in the range 0 to 31, inclusive, as if value2 were subjected to a bitwise logical AND with the mask value 0x1f.


istore

Operation Store int into local variable

istore
index


Forms istore = 54 (0x36)

Stack ..., value ...

Description The index is an unsigned byte that must be a valid index into the local variables of the current frame (§3.6). The value on the top of the operand stack must be of type int. It is popped from the operand stack, and the value of the local variable at index is set to value.

Notes The istore opcode can be used in conjunction with the wide instruction to access a local variable using a two-byte unsigned index.


istore_<n>

Operation Store int into local variable

istore_<n>


Forms istore_0 = 59 (0x3b)

istore_1 = 60 (0x3c)

istore_2 = 61 (0x3d)

istore_3 = 62 (0x3e)

Stack ..., value ...

Description The <n> must be a valid index into the local variables of the current frame (§3.6). The value on the top of the operand stack must be of type int. It is popped from the operand stack, and the value of the local variable at <n> is set to value.

Notes Each of the istore_<n> instructions is the same as istore with an index of <n>, except that the operand <n> is implicit.


isub

Operation Subtract int

isub


Forms isub = 100 (0x64)

Stack ..., value1, value2 ..., result

Description Both value1 and value2 must be of type int. The values are popped from the operand stack. The int result is value1 - value2. The result is pushed onto the operand stack.

For int subtraction, a - b produces the same result as a + (-b). For int values, subtraction from zero is the same as negation.

Despite the fact that overflow or underflow may occur, in which case the result may have a different sign than the true mathematical result, execution of an isub instruction never throws a runtime exception.


iushr

Operation Logical shift right

iushr


int

Forms iushr = 124 (0x7c)

Stack ..., value1, value2 ..., result

Description Both value1 and value2 must be of type int. The values are popped from the operand stack. An int result is calculated by shifting value1 right by s bit positions, with zero extension, where s is the value of the low five bits of value2. The result is pushed onto the operand stack.

If value1 is positive and s is value2 & 0x1f, the result is the same as that of value1 >> s; if value1 is negative, the result is equal to the value of the expression (value1 >> s) + (2 << ~s). The addition of the (2 << ~s) term cancels out the propagated sign bit. The shift distance actually used is always in the range 0 to 31, inclusive.

If value1 is positive and s is value2 & 0x1f, the result is the same as that of value1 \>\> s; if value1 is negative, the result is equal to the value of the expression (value1 \>\> s) + (2 << ~s). The addition of the (2 << ~s) term cancels out the propagated sign bit. The shift distance actually used is always in the range 0 to 31, inclusive.


ixor

Operation Boolean XOR int

ixor


Forms ixor = 130 (0x82)

Stack ..., value1, value2 ..., result

Description Both value1 and value2 must both be of type int. They are popped from the operand stack. An int result is calculated by taking the bitwise exclusive OR of value1 and value2. The result is pushed onto the operand stack.

jsr jsr

Operation Jump subroutine

jsr
branchbyte1
branchbyte2


Forms jsr = 168 (0xa8)

Stack ... ..., address

Description The address of the opcode of the instruction immediately following this jsr instruction is pushed onto the operand stack as a value of type returnAddress. The unsigned branchbyte1 and branchbyte2 are used to construct a signed 16-bit offset, where the offset is (branchbyte1 << 8) | branchbyte2. Execution proceeds at that offset from the address of this jsr instruction. The target address must be that of an opcode of an instruction within the method that contains this jsr instruction.

Notes The jsr instruction is used with the ret instruction in the implementation of the finally clauses of the Java language (see Section 7.13, "Compiling finally"). Note that jsr pushes the address onto the stack and ret gets it out of a local variable. This asymmetry is intentional.


jsr_w

Operation Jump subroutine (wide index)

jsr_w
branchbyte1
branchbyte2
branchbyte3
branchbyte4


Forms jsr_w = 201 (0xc9)

Stack ... ..., address

Description The address of the opcode of the instruction immediately following this jsr_w instruction is pushed onto the operand stack as a value of type returnAddress. The unsigned branchbyte1, branchbyte2, branchbyte3, and branchbyte4 are used to construct a signed 32-bit offset, where the offset is (branchbyte1 << 24) | (branchbyte2 << 16) | (branchbyte3 << 8) | branchbyte4. Execution proceeds at that offset from the address of this jsr_w instruction. The target address must be that of an opcode of an instruction within the method that contains this jsr_w instruction.

Notes The jsr_w instruction is used with the ret instruction in the implementation of the finally clauses of the Java language (see Section 7.13, "Compiling finally"). Note that jsr_w pushes the address onto the stack and ret gets it out of a local variable. This asymmetry is intentional.

Although the jsr_w instruction has a 4-byte branch offset, other factors limit the size of a Java method to 65535 bytes (§4.10). This limit may be raised in a future release of the Java Virtual Machine.


Contents | Prev | Next | Index

Java Virtual Machine Specification