Contents | Prev | Next | Index | The Java^{TM} Virtual Machine Specification |

**Operation**

Convert`long`

to`double`

Format

l2d

**Forms**

l2d= 138 (0x8a)

**Operand Stack**

...,value...,result

**Description**

Thevalueon the top of the operand stack must be of type`long`

. It is popped from the operand stack and converted to a`double`

resultusing IEEE 754 round to nearest mode. Theresultis pushed onto the operand stack.

**Notes**

Thel2dinstruction performs a widening primitive conversion (§2.6.2) that may lose precision because values of type`double`

have only 53 significand bits.

**Operation**

Convert`long`

to`float`

Format

l2f

**Forms**

l2f= 137 (0x89)

**Operand Stack**

...,value...,result

**Description**

Thevalueon the top of the operand stack must be of type`long`

. It is popped from the operand stack and converted to a`float`

resultusing IEEE 754 round to nearest mode. Theresultis pushed onto the operand stack.

**Notes**

Thel2finstruction performs a widening primitive conversion (§2.6.2) that may lose precision because values of type`float`

have only 24 significand bits.

**Operation**

Convert`long`

to`int`

Format

l2i

**Forms**

l2i= 136 (0x88)

**Operand Stack**

...,value...,result

**Description**

Thevalueon the top of the operand stack must be of type`long`

. It is popped from the operand stack and converted to an`int`

resultby taking the low-order 32 bits of the`long`

value and discarding the high-order 32 bits. Theresultis pushed onto the operand stack.

**Notes**

Thel2iinstruction performs a narrowing primitive conversion (§2.6.3). It may lose information about the overall magnitude ofvalue. Theresultmay also not have the same sign asvalue.

**Operation**

Add`long`

Format

ladd

**Forms**

ladd= 97 (0x61)

**Operand Stack**

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

**Description**

Bothvalue1andvalue2must be of type`long`

. The values are popped from the operand stack. The`long`

resultisvalue1+value2. Theresultis pushed onto the operand stack.

```
The result is the 64 low-order bits of the true mathematical result in a sufficiently wide two's-complement format, represented as a value of type
````long`

. If overflow occurs, the sign of the result may not be the same as the sign of the mathematical sum of the two values.

Despite the fact that overflow may occur, execution of anladdinstruction never throws a runtime exception.

**Operation**

Load`long`

from array

Format

laload

**Forms**

laload= 47 (0x2f)

**Operand Stack**

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

**Description**

Thearrayrefmust be of type`reference`

and must refer to an array whose components are of type`long`

. Theindexmust be of type`int`

. Botharrayrefandindexare popped from the operand stack. The`long`

valuein the component of the array atindexis retrieved and pushed onto the operand stack.

**Runtime Exceptions**

Ifarrayrefis`null`

,laloadthrows a`NullPointerException`

.

Otherwise, ifindexis not within the bounds of the array referenced byarrayref, thelaloadinstruction throws an`ArrayIndexOutOfBoundsException`

.

**Operation**

Boolean AND`long`

Format

land

**Forms**

land= 127 (0x7f)

**Operand Stack**

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

**Description**

Bothvalue1andvalue2must be of type`long`

. They are popped from the operand stack. A`long`

resultis calculated by taking the bitwise AND ofvalue1andvalue2. Theresultis pushed onto the operand stack.

**Operation**

Store into`long`

array

Format

lastore

**Forms**

lastore= 80 (0x50)

**Operand Stack**

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

**Description**

Thearrayrefmust be of type`reference`

and must refer to an array whose components are of type`long`

. Theindexmust be of type`int`

, andvaluemust be of type`long`

. Thearrayref,index, andvalueare popped from the operand stack. The`long`

valueis stored as the component of the array indexed byindex.

**Runtime Exceptions**

Ifarrayrefis`null`

,lastorethrows a`NullPointerException`

.

Otherwise, ifindexis not within the bounds of the array referenced byarrayref, thelastoreinstruction throws an`ArrayIndexOutOfBoundsException`

.

**Operation**

Compare`long`

Format

lcmp

**Forms**

lcmp= 148 (0x94)

**Operand Stack**

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

**Description**

Bothvalue1andvalue2must be of type`long`

. They are both popped from the operand stack, and a signed integer comparison is performed. Ifvalue1is greater thanvalue2, the`int`

value 1 is pushed onto the operand stack. Ifvalue1is equal tovalue2, the`int`

value 0 is pushed onto the operand stack. Ifvalue1is less thanvalue2, the`int`

value -1 is pushed onto the operand stack.

**Operation**

Push`long`

constant

Format

lconst_<l>

**Forms**

lconst_0= 9 (0x9)lconst_1= 10 (0xa)

**Operand Stack**

... ...,<l>

**Description**

Push the`long`

constant<l>(0or1) onto the operand stack.

**Operation**

Push item from runtime constant pool

Format

ldcindex

**Forms**

ldc= 18 (0x12)

**Operand Stack**

... ...,value

**Description**

Theindexis an unsigned byte that must be a valid index into the runtime constant pool of the current class (§3.6). The runtime constant pool entry atindexeither must be a runtime constant of type`int`

or`float`

, or must be a symbolic reference to a string literal (§5.1).

If the runtime constant pool entry is a runtime constant of type`int`

or`float`

, the numericvalueof that runtime constant is pushed onto the operand stack as an`int`

or`float`

, respectively.

Otherwise, the runtime constant pool entry must be a reference to an instance of class`String`

representing a string literal (§5.1). A`reference`

to that instance,value, is pushed onto the operand stack.

**Notes**

Theldcinstruction can only be used to push a value of type`float`

taken from the float value set (§3.3.2) because a constant of type`float`

in the constant pool (§4.4.4) must be taken from the float value set.

**Operation**

Push item from runtime constant pool (wide index)

Format

ldc_windexbyte1indexbyte2

**Forms**

ldc_w= 19 (0x13)

**Operand Stack**

... ...,value

**Description**

The unsignedindexbyte1andindexbyte2are assembled into an unsigned 16-bit index into the runtime constant pool of the current class (§3.6), where the value of the index is calculated as (indexbyte1<< 8) |indexbyte2. The index must be a valid index into the runtime constant pool of the current class. The runtime constant pool entry at the index either must be a runtime constant of type`int`

or`float`

, or must be a symbolic reference to a string literal (§5.1).

If the runtime constant pool entry is a runtime constant of type`int`

or`float`

, the numericvalueof that runtime constant is pushed onto the operand stack as an`int`

or`float`

, respectively.

Otherwise, the runtime constant pool entry must be a reference to an instance of class`String`

representing a string literal (§5.1). A`reference`

to that instance,value, is pushed onto the operand stack.

**Notes**

Theldc_winstruction is identical to theldcinstruction except for its wider runtime constant pool index.

Theldc_winstruction can only be used to push a value of type`float`

taken from the float value set (§3.3.2) because a constant of type`float`

in the constant pool (§4.4.4) must be taken from the float value set.

**Operation**

Push`long`

or`double`

from runtime constant pool (wide index)

Format

ldc2_windexbyte1indexbyte2

**Forms**

ldc2_w= 20 (0x14)

**Operand Stack**

... ...,value

**Description**

The unsignedindexbyte1andindexbyte2are assembled into an unsigned 16-bit index into the runtime constant pool of the current class (§3.6), where the value of the index is calculated as (indexbyte1<< 8) |indexbyte2. The index must be a valid index into the runtime constant pool of the current class. The runtime constant pool entry at the index must be a runtime constant of type`long`

or`double`

(§5.1). The numericvalueof that runtime constant is pushed onto the operand stack as a`long`

or`double`

, respectively.

**Notes**

Only a wide-index version of theldc2_winstruction exists; there is noldc2instruction that pushes a`long`

or`double`

with a single-byte index.

Theldc2_winstruction can only be used to push a value of type`double`

taken from the double value set (§3.3.2) because a constant of type`double`

in the constant pool (§4.4.5) must be taken from the double value set.

**Operation**

Divide`long`

Format

ldiv

**Forms**

ldiv= 109 (0x6d)

**Operand Stack**

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

**Description**

Bothvalue1andvalue2must be of type`long`

. The values are popped from the operand stack. The`long`

resultis the value of the Java programming language expressionvalue1/value2. Theresultis pushed onto the operand stack.

A`long`

division rounds towards 0; that is, the quotient produced for`long`

values inn/dis a`long`

valueqwhose magnitude is as large as possible while satisfying . Moreover,qis positive when andnanddhave the same sign, butqis negative when andnanddhave 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`long`

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 a`long`

division is 0,ldivthrows an`ArithmeticException`

.

**Operation**

Load`long`

from local variable

Format

lloadindex

**Forms**

lload= 22 (0x16)

**Operand Stack**

... ...,value

**Description**

Theindexis an unsigned byte. Bothindexandindex+ 1 must be indices into the local variable array of the current frame (§3.6). The local variable atindexmust contain a`long`

. Thevalueof the local variable atindexis pushed onto the operand stack.

**Notes**

Thelloadopcode can be used in conjunction with thewideinstruction to access a local variable using a two-byte unsigned index.

**Operation**

Load`long`

from local variable

Format

lload_<n>

**Forms**

lload_0= 30 (0x1e)lload_1= 31 (0x1f)lload_2= 32 (0x20)lload_3= 33 (0x21)

**Operand Stack**

... ...,value

**Description**

Both<n>and<n>+1must be indices into the local variable array of the current frame (§3.6). The local variable at<n>must contain a`long`

. Thevalueof the local variable at<n>is pushed onto the operand stack.

**Notes**

Each of thelload_<n>instructions is the same aslloadwith anindexof<n>, except that the operand<n>is implicit.

**Operation**

Multiply`long`

Format

lmul

**Forms**

lmul= 105 (0x69)

**Operand Stack**

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

**Description**

Bothvalue1andvalue2must be of type`long`

. The values are popped from the operand stack. The`long`

resultisvalue1*value2. Theresultis pushed onto the operand stack.

```
The result is the 64 low-order bits of the true mathematical result in a sufficiently wide two's-complement format, represented as a value of type
````long`

. If overflow occurs, the sign of the result may not be the same as the sign of the mathematical sum of the two values.

Despite the fact that overflow may occur, execution of anlmulinstruction never throws a runtime exception.

**Operation**

Negate`long`

Format

lneg

**Forms**

lneg= 117 (0x75)

**Operand Stack**

...,value...,result

**Description**

Thevaluemust be of type`long`

. It is popped from the operand stack. The`long`

resultis the arithmetic negation ofvalue, -value. Theresultis pushed onto the operand stack.

For`long`

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`long`

results in that same maximum negative number. Despite the fact that overflow has occurred, no exception is thrown.

For all`long`

values`x`

, -`x`

equals (~`x`

) +`1`

.

**Operation**

Access jump table by key match and jump

Format

lookupswitch< 0-3 byte pad\>defaultbyte1defaultbyte2defaultbyte3defaultbyte4npairs1npairs2npairs3npairs4match-offset pairs...

**Forms**

lookupswitch= 171 (0xab)

**Operand Stack**

...,key...

**Description**

Alookupswitchis a variable-length instruction. Immediately after thelookupswitchopcode, between zero and three null bytes (zeroed bytes, not the null object) are inserted as padding. The number of null bytes is chosen so that thedefaultbyte1begins at an address that is a multiple of four bytes from the start of the current method (the opcode of its first instruction). Immediately after the padding follow a series of signed 32-bit values:default,npairs, and thennpairspairs of signed 32-bit values. Thenpairsmust be greater than or equal to 0. Each of thenpairspairs consists of an`int`

matchand a signed 32-bitoffset. Each of these signed 32-bit values is constructed from four unsigned bytes as (byte1<< 24) | (byte2<< 16) | (byte3<< 8) |byte4.

The tablematch-offsetpairs of thelookupswitchinstruction must be sorted in increasing numerical order bymatch.

Thekeymust be of type`int`

and is popped from the operand stack. Thekeyis compared against thematchvalues. If it is equal to one of them, then a target address is calculated by adding the correspondingoffsetto the address of the opcode of thislookupswitchinstruction. If thekeydoes not match any of thematchvalues, the target address is calculated by addingdefaultto the address of the opcode of thislookupswitchinstruction. Execution then continues at the target address.

The target address that can be calculated from the offset of eachmatch-offsetpair, as well as the one calculated fromdefault, must be the address of an opcode of an instruction within the method that contains thislookupswitchinstruction.

**Notes**

The alignment required of the 4-byte operands of thelookupswitchinstruction guarantees 4-byte alignment of those operands if and only if the method that contains thelookupswitchis positioned on a 4-byte boundary.

Thematch-offsetpairs are sorted to support lookup routines that are quicker than linear search.

**Operation**

Boolean OR`long`

Format

lor

**Forms**

lor= 129 (0x81)

**Operand Stack**

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

**Description**

Bothvalue1andvalue2must be of type`long`

. They are popped from the operand stack. A`long`

resultis calculated by taking the bitwise inclusive OR ofvalue1andvalue2. Theresultis pushed onto the operand stack.

**Operation**

Remainder`long`

Format

lrem

**Forms**

lrem= 113 (0x71)

**Operand Stack**

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

**Description**

Bothvalue1andvalue2must be of type`long`

. The values are popped from the operand stack. The`long`

resultisvalue1- (value1/value2) *value2. Theresultis pushed onto the operand stack.

The result of thelreminstruction is such that (`a`

/`b`

)*`b`

+ (`a%b`

) is equal to`a`

. This identity holds even in the special case in which the dividend is the negative`long`

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 a`long`

remainder operator is`0`

,lremthrows an`ArithmeticException`

.

**Operation**

Return`long`

from method

Format

lreturn

**Forms**

lreturn= 173 (0xad)

**Operand Stack**

...,value[empty]

**Description**

The current method must have return type`long`

. Thevaluemust be of type`long`

. If the current method is a`synchronized`

method, the monitor acquired or reentered on invocation of the method is released or exited (respectively) as if by execution of amonitorexitinstruction. If no exception is thrown,valueis 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.

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

**Runtime Exceptions**

If the current method is a`synchronized`

method and the current thread is not the owner of the monitor acquired or reentered on invocation of the method,lreturnthrows an`IllegalMonitorStateException`

. This can happen, for example, if a`synchronized`

method contains amonitorexitinstruction, but nomonitorenterinstruction, on the object on which the method is synchronized.

Otherwise, if the virtual machine implementation enforces the rules on structured use of locks described in Section 8.13 and if the first of those rules is violated during invocation of the current method, thenlreturnthrows an`IllegalMonitorStateException`

.

**Operation**

Shift left

Format

lshl

`long`

**Forms**

lshl= 121 (0x79)

**Operand Stack**

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

**Description**

Thevalue1must be of type`long`

, andvalue2must be of type`int`

. The values are popped from the operand stack. A`long`

resultis calculated by shiftingvalue1left bysbit positions, wheresis the low 6 bits ofvalue2. Theresultis pushed onto the operand stack.

**Notes**

This is equivalent (even if overflow occurs) to multiplication by 2 to the powers. The shift distance actually used is therefore always in the range 0 to 63, inclusive, as ifvalue2were subjected to a bitwise logical AND with the mask value 0x3f.

**Operation**

Arithmetic shift right`long`

Format

lshr

**Forms**

lshr= 123 (0x7b)

**Operand Stack**

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

**Description**

Thevalue1must be of type`long`

, andvalue2must be of type`int`

. The values are popped from the operand stack. A`long`

resultis calculated by shiftingvalue1right bysbit positions, with sign extension, wheresis the value of the low 6 bits ofvalue2. Theresultis pushed onto the operand stack.

**Notes**

The resulting value is , wheresisvalue2& 0x3f. For nonnegativevalue1, this is equivalent to truncating`long`

division by 2 to the power`s`

. The shift distance actually used is therefore always in the range 0 to 63, inclusive, as ifvalue2were subjected to a bitwise logical AND with the mask value 0x3f.

**Operation**

Store`long`

into local variable

Format

lstoreindex

**Forms**

lstore= 55 (0x37)

**Operand Stack**

...,value...

**Description**

Theindexis an unsigned byte. Bothindexandindex+1must be indices into the local variable array of the current frame (§3.6). Thevalueon the top of the operand stack must be of type`long`

. It is popped from the operand stack, and the local variables atindexandindex+1are set tovalue.

**Notes**

Thelstoreopcode can be used in conjunction with thewideinstruction to access a local variable using a two-byte unsigned index.

**Operation**

Store`long`

into local variable

Format

lstore_<n>

**Forms**

lstore_0= 63 (0x3f)lstore_1= 64 (0x40)lstore_2= 65 (0x41)lstore_3= 66 (0x42)

**Operand Stack**

...,value...

**Description**

Both<n>and<n>+1must be indices into the local variable array of the current frame (§3.6). Thevalueon the top of the operand stack must be of type`long`

. It is popped from the operand stack, and the local variables at<n>and<n>+1are set tovalue.

**Notes**

Each of thelstore_<n>instructions is the same aslstorewith anindexof<n>, except that the operand<n>is implicit.

**Operation**

Subtract`long`

Format

lsub

**Forms**

lsub= 101 (0x65)

**Operand Stack**

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

**Description**

Bothvalue1andvalue2must be of type`long`

. The values are popped from the operand stack. The`long`

resultisvalue1-value2. Theresultis pushed onto the operand stack.

For`long`

subtraction,`a`

-`b`

produces the same result as`a`

+`(`

-`b)`

. For`long`

values, subtraction from zero is the same as negation.

```
The result is the 64 low-order bits of the true mathematical result in a sufficiently wide two's-complement format, represented as a value of type
````long`

. If overflow occurs, then the sign of the result may not be the same as the sign of the mathematical sum of the two values.

Despite the fact that overflow may occur, execution of anlsubinstruction never throws a runtime exception.

**Operation**

Logical shift right`long`

Format

lushr

**Forms**

lushr= 125 (0x7d)

**Operand Stack**

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

**Description**

Thevalue1must be of type`long`

, andvalue2must be of type`int`

. The values are popped from the operand stack. A`long`

resultis calculated by shiftingvalue1right logically (with zero extension) by the amount indicated by the low 6 bits ofvalue2. Theresultis pushed onto the operand stack.

**Notes**

Ifvalue1is positive and s isvalue2& 0x3f, the result is the same as that ofvalue1>> s; ifvalue1is negative, the result is equal to the value of the expression (value1>> s) + (2L << ~s). The addition of the (2L << ~s) term cancels out the propagated sign bit. The shift distance actually used is always in the range 0 to 63, inclusive.

**Operation**

Boolean XOR`long`

Format

lxor

**Forms**

lxor= 131 (0x83)

**Operand Stack**

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

**Description**

Bothvalue1andvalue2must be of type`long`

. They are popped from the operand stack. A`long`

resultis calculated by taking the bitwise exclusive OR ofvalue1andvalue2. Theresultis pushed onto the operand stack.

Contents | Prev | Next | Index

*The Java*^{TM}* Virtual Machine Specification *

*Copyright © 1999 Sun Microsystems, Inc.
All rights reserved*

Please send any comments or corrections to [email protected]