appa Instruction Set by Opcode Mnemonic

Orders Orders Backward   Forward
Comments Comments
1997 The McGraw-Hill Companies, Inc. All rights reserved.
Any use of this Beta Book is subject to the rules stated in the Terms of Use.

Instruction Set by Opcode Mnemonic

Appendix A lists Java Virtual Machine instructions in alphabetical order by opcode mnemonic. All 201 instructions that may legally appear in the bytecode streams stored in Java class files are described in detail in Appendix A.

Besides the opcodes for the 201 instructions that may appear in class files, the Java Virtual Machine specification describes two other families of opcodes: the reserved opcodes and the " _quick " opcodes. None of these opcodes can legally appear in the bytecode streams of Java class files.

The Java Virtual Machine specification lists three reserved opcodes, which are shown in Table A-1. These opcodes are reserved for internal use by Java Virtual Machine implementations and tools. The specification guarantees that these three opcodes will not be part of any future extension of the Java Virtual Machine ­s instruction set. As you may have guessed, the intended purpose of the breakpoint opcode is to provide a way for debuggers to implement breakpoints. The intended purpose of the other two reserved opcodes, impdep1 and impdep2 , is to serve as "back doors" to implementation-dependent software functionality or "traps" to implementation-dependent hardware functionality.

Table A-1. The reserved opcodes

mnemonic byte value
breakpoint 202 (0xca)
impdep1 254 (0xfe)
impdep2 255 (0xff)

The Java Virtual Machine specification also lists 25 " _quick " opcodes, which Sun ­s virtual machine implementation uses internally to speed up the interpreted execution of bytecodes. This optimization technique is described in general in this book in Chapter 8, "The Linking Model," but the individual " _quick " instructions are not described in detail in Appendix A. (The " _quick " opcodes do appear in Appendix C, which lists their mnemonics and corresponding opcode byte values.) Like the reserved opcodes, the " _quick " opcodes may not legally appear in Java class files. But unlike the reserved opcodes, the Java Virtual Machine specification leaves open the possibility that these opcodes will take on new meanings in future extensions of the instruction set.

For each instruction listed in Appendix A, you will find the following information:

  • the mnemonic
  • a short description
  • the opcode ­s byte value in decimal and hex
  • the format of the instruction
  • the operand stack before and after the instruction is executed
  • a description of any constraints associated with the instruction
  • a description of the execution of the instruction
  • a description of any exceptions or errors that may be thrown by the instruction

The format of each instruction appears as a list of comma-separated items next to the label "Instruction Format," with each item representing one byte in the bytecode stream. The opcode mnemonic appears first (in fixed-width font), followed by any operands (shown in italics).

For each instruction, Appendix A shows two snapshots of the operand stack. One snapshot, labelled "Before," shows the contents of the current method ­s operand stack just before the instruction is executed. The other snapshot, labelled "After," shows the operand stack immediately after execution of the instruction. In both snapshots, the operand stack appears as a list of comma-separated items, with each item representing one word. Although everywhere else in this book the operand stack is shown growing downwards (the top of the stack appears at the bottom of the picture), in Appendix A the operand stack is shown growing sideways , from left to right. In each snapshot, the top of the stack is the rightmost item shown. Unaffected portions of the operand stack are shown as an elipsis, "...".

For each instruction, the section labelled "Description" combines three kinds of information: constraints, the process of execution, and exceptions and errors. As mentioned in Chapter 3, "Security," Java Virtual Machine implementations are required to enforce at run-time certain constraints on the bytecodes of every method they execute. Whenever you see the word "must" in an instruction ­s description in Appendix A, you are reading about a constraint every implementation must enforce when executing the instruction. For example, the goto instruction, which causes an unconditional jump, may only cause a jump to another opcode of the same method. In Appendix A ­s description for goto , this constraint is stated as, "The target address must be the address of an opcode within the same method as the goto opcode."

The designers of each individual Java Virtual Machine implementation can decide how and when to detect violations of the bytecode constraints. If any implementation detects a constraint violation, it must report the violation by throwing a VerifyError when (and if) the running program attempts to execute the instruction.

In addition to describing the constraints placed on each instruction, Appendix A describes the process of executing each instruction and lists any errors or exceptions that may be thrown during the course of executing the instruction. Besides the errors and exceptions explicitly listed in the instruction descriptions, one other family of errors, subclasses of VirtualMachineError , can be thrown at any time as the result of executing any instruction. Four subclasses of VirtualMachineError , and the circumstances under which they will be thrown, are:

  • OutOfMemoryError - the virtual machine has run out of real or virtual memory, and the garbage collector can ­t reclaim enough space to enable the thread to continue.
  • StackOverflowError - a thread has exhausted its supply of memory for stack space (usually because the application has an unbounded recursion).
  • InternalError - the virtual machine has encountered a bug in its own implementation that prevents it from properly implementing the semantics of the Java language.
  • UnknownError - the virtual machine has encountered some error condition, but is unable to report the actual condition by throwing the appropriate exception or error.

aaload

- Load reference from array

Opcode:

50 (0x32)

Instruction Format:

aaload

Stack:

Before: ..., arrayref, index

After: ..., value

Description:

To execute the iaload instruction, the Java Virtual Machine first pops two words from the operand stack. The arrayref word must be a reference that refers to an array of reference s. The index word must be an int . The virtual machine retrieves from the arrayref array the reference value specified by index and pushes it onto the operand stack.

If arrayref is null , the Java Virtual Machine throws NullPointerException . Otherwise, if index is not a legal index into the arrayref array, the virtual machine throws ArrayIndexOutOfBoundsException .

For more information about the aaload instruction, see Chapter 15, "Objects and Arrays."

aastore

- Store reference into array

Opcode:

83 (0x53)

Instruction Format:

aastore

Stack:

Before: ..., arrayref, index, value

After: ...

Description:

To execute the aaload instruction, the Java Virtual Machine first pops three words from the operand stack. The arrayref word must be a reference that refers to an array of float s. The index word must be an int , and the value word must be a reference . The type of value must be assignment compatible with the component type of the arrayref array. The virtual machine stores reference value into the arrayref array location specified by index .

If arrayref is null , the Java Virtual Machine throws NullPointerException . Else, if index is not a legal index into the arrayref array, the virtual machine throws ArrayIndexOutOfBoundsException . Otherwise, if the actual type of value is not assignment compatible with the actual type of the components of the arrayref array, the virtual machine throws ArrayStoreException .

For more information about the aastore instruction, see Chapter 15, "Objects and Arrays."

aconst_null

- Push null object reference

Opcode:

1 (0x1)

Instruction Format:

aconst_null

Stack:

Before: ...

After: ..., null

Description:

To execute the aconst_null instruction, the Java Virtual Machine pushes a null object reference onto the operand stack. (Note that the Java Virtual Machine specification does not dictate any actual value for null . The specification leaves that decision to the designers of each individual implementation.)

For more information about the aconst_null instruction, see Chapter 10, "Stack Operations."

aload

- Load reference from local variable

Opcode:

25 (0x19)

Instruction Format:

aload , index

Stack:

Before:...

After: ..., value

Description:

The index operand, which serves as an 8-bit unsigned index into the local variables of the current frame, must specify a local variable word that contains a reference . To execute the aload instruction, the Java Virtual Machine pushes onto the operand stack the reference contained in the local variable word specified by index .

Note that the wide instruction can precede the aload instruction, to allow a local variable to be accessed with a 16-bit unsigned offset.

Note also that even though the astore instruction may be used to pop a returnAddress value off the operand stack and into a local variable, the aload instruction cannot be used to push a returnAddress value back onto the operand stack. For more information about the use of returnAddress , see Chapter 18, "Finally Clauses."

For more information about the aload instruction, see Chapter 10, "Stack Operations."

aload_0

- Load reference from local variable 0

Opcode:

42 (0x2a)

Instruction Format:

aload_0

Stack:

Before: ...

After: ..., value

Description:

The local variable word at index zero must contain a reference . To execute the aload_0 instruction, the Java Virtual Machine pushes onto the operand stack the reference value contained in the local variable word zero.

Note that even though the astore_0 instruction may be used to pop a returnAddress value off the operand stack and into a local variable, the aload_0 instruction cannot be used to push a returnAddress value back onto the operand stack. For more information about the use of returnAddress , see Chapter 18, "Finally Clauses."

For more information about the aload_0 instruction, see Chapter 10, "Stack Operations."

aload_1

- Load reference from local variable 1

Opcode:

43 (0x2b)

Instruction Format:

aload_1

Stack:

Before: ...

After: ..., value

Description:

The local variable word at index one must contain a reference . To execute the aload_1 instruction, the Java Virtual Machine pushes onto the operand stack the reference value contained in the local variable word one.

Note that even though the astore_1 instruction may be used to pop a returnAddress value off the operand stack and into a local variable, the aload_1 instruction cannot be used to push a returnAddress value back onto the operand stack. For more information about the use of returnAddress , see Chapter 18, "Finally Clauses."

For more information about the aload_1 instruction, see Chapter 10, "Stack Operations."

aload_2

- Load reference from local variable 2

Opcode:

44 (0x2c)

Instruction Format:

aload_2

Stack:

Before: ...

After: ..., value

Description:

The local variable word at index two must contain a reference . To execute the aload_2 instruction, the Java Virtual Machine pushes onto the operand stack the reference value contained in the local variable word two.

Note that even though the astore_2 instruction may be used to pop a returnAddress value off the operand stack and into a local variable, the aload_2 instruction cannot be used to push a returnAddress value back onto the operand stack. For more information about the use of returnAddress , see Chapter 18, "Finally Clauses."

For more information about the aload_2 instruction, see Chapter 10, "Stack Operations."

aload_3

- Load reference from local variable 3

Opcode:

45 (0x2d)

Instruction Format:

aload_3

Stack:

Before: ...

After: ..., value

Description:

The local variable word at index three must contain a reference . To execute the aload_3 instruction, the Java Virtual Machine pushes onto the operand stack the reference value contained in the local variable word three.

Note that even though the astore_3 instruction may be used to pop a returnAddress value off the operand stack and into a local variable, the aload_3 instruction cannot be used to push a returnAddress value back onto the operand stack. For more information about the use of returnAddress , see Chapter 18, "Finally Clauses."

For more information about the aload_3 instruction, see Chapter 10, "Stack Operations."

anewarray

- Allocate new array of reference type components

Opcode:

189 (0xbd)

Instruction Format:

anewarray , indexbyte1 , indexbyte2

Stack:

Before:..., count

After: arrayref

Description:

The top word of the operand stack, count , must be an int . To execute the anewarray instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the constant pool by calculating (indexbyte1 8) | indexbyte2 . The virtual machine then looks up the constant pool entry specified by the calculated index. The constant pool entry at that index must be a CONSTANT_Class_info entry. If it hasn ­t already, the virtual machine resolves the entry. The entry may be a class, interface, or array type.

If the resolution is successful, the Java Virtual Machine pops count and creates on the heap an array of size count of the reference type specified by the resolved CONSTANT_Class_info entry. The virtual machine initializes each array element to its default initial value ( null ) and pushes arrayref , a reference to the new array, onto the operand stack.

As a result of executing this instruction, the Java Virtual Machine may throw any of the linking errors listed in Chapter 8, "The Linking Model," as possible during resolution of a CONSTANT_Class_info entry. If resolution succeeds, but count is less than zero, the virtual machine throws NegativeArraySizeException .

For more information about the anewarray instruction, see Chapter 15, "Objects and Arrays."

areturn

- Return reference from method

Opcode:

176 (0xb0)

Instruction Format:

areturn

Stack:

Before: ..., objectref

After: [empty]

Description:

The return type of the returning method must be reference . The top word of the operand stack, objectref , must be a reference that is assignment compatible with the type represented by the returning method ­s descriptor. To execute the areturn instruction, the Java Virtual Machine pops objectref from the operand stack of the current frame and pushes it onto the operand stack of the invoking method ­s frame. The virtual machine discards any other words that may still be on the returning method ­s frame. If the returning method is synchronized, the monitor that was acquired when the method was invoked is released. The invoking method ­s frame is made current, and the virtual machine continues execution in the invoking method.

For more information about monitors , see Chapter 20, "Thread Synchronization." For more information about the areturn instruction, see Chapter 19, "Method Invocation and Return."

arraylength

- Get length of array

Opcode:

190 (0xbe)

Instruction Format:

arraylength

Stack:

Before: ..., arrayref

After: ..., length

Description:

The top word of the operand stack, arrayref , must be a reference that points to an array. To execute the arraylength instruction, the Java Virtual Machine pops arrayref and pushes the length of the array pointed to by arrayref .

If arrayref is null , the Java Virtual Machine throws NullPointerException .

For more information about the arraylength instruction, see Chapter 15, "Objects and Arrays."

astore

- Store reference or returnAddress into local variable

Opcode:

58 (0x3a)

Instruction Format:

astore , index

Stack:

Before:..., value

After: ...

Description:

The index operand must specify a valid 8-bit unsigned index into the local variables of the current frame. The value on the top of the operand stack must be a reference or a returnAddress . To execute the astore instruction, the Java Virtual Machine pops the reference or returnAddress value from the top of the operand stack and stores it into the local variable word specified by index .

Note that the wide instruction can precede the astore instruction, to enable a value to be stored into a local variable specified by a 16-bit unsigned offset.

For more information about the astore instruction, see Chapter 10, "Stack Operations."

astore_0

- Store reference or returnAddress into local variable 0

Opcode:

75 (0x4b)

Instruction Format:

astore_0

Stack:

Before: ..., value

After: ...

Description:

The index zero must be a valid index into the local variables of the current stack frame, and the value word on the top of the operand stack must be a reference or a returnAddress . To execute the astore_0 instruction, the Java Virtual Machine pops the reference or returnAddress value from the top of the operand stack and stores it into the local variable word at index zero.

For more information about the astore_0 instruction, see Chapter 10, "Stack Operations."

astore_1

- Store reference or returnAddress into local variable 1

Opcode:

76 (0x4c)

Instruction Format:

astore_1

Stack:

Before: ..., value

After: ...

Description:

The index one must be a valid index into the local variables of the current stack frame, and the value word on the top of the operand stack must be a reference or a returnAddress . To execute the astore_1 instruction, the Java Virtual Machine pops the reference or returnAddress value from the top of the operand stack and stores it into the local variable word at index one.

For more information about the astore_1 instruction, see Chapter 10, "Stack Operations."

astore_2

- Store reference or returnAddress into local variable 2

Opcode:

77 (0x4d)

Instruction Format:

astore_2

Stack:

Before: ..., value

After: ...

Description:

The index two must be a valid index into the local variables of the current stack frame, and the value word on the top of the operand stack must be a reference or a returnAddress . To execute the astore_2 instruction, the Java Virtual Machine pops the reference or returnAddress value from the top of the operand stack and stores it into the local variable word at index two.

For more information about the astore_2 instruction, see Chapter 10, "Stack Operations."

astore_3

- Store reference or returnAddress into local variable 3

Opcode:

78 (0x4e)

Instruction Format:

astore_3

Stack:

Before: ..., value

After: ...

Description:

The index three must be a valid index into the local variables of the current stack frame, and the value word on the top of the operand stack must be a reference or a returnAddress . To execute the astore_3 instruction, the Java Virtual Machine pops the reference or returnAddress value from the top of the operand stack and stores it into the local variable word at index three.

For more information about the astore_3 instruction, see Chapter 10, "Stack Operations."

athrow

- Throw exception or error

Opcode:

191 (0xbf)

Instruction Format:

athrow

Stack:

Before: ..., objectref

After objectref

Note that "Before" shows the operand stack of the frame belonging to the method containing the athrow instruction being executed. "After" shows the operand stack of the frame belonging to the method in which the catch clause is found, if a catch clause is found. If no catch clause is found, the thread exits and there are no more operand stacks for that thread.

Description:

The top word of the operand stack, objectref , must be a reference that points either to an instance of class java.lang.Throwable or to an instance of some subclass of java.lang.Throwable . To execute the athrow instruction, the Java Virtual Machine pops objectref from the operand stack. The virtual machine "throws" the exception by searching through the current method ­s exception table for the most recent catch clause that catches either the class of the throwable object pointed to by objectref , or a subclass of the throwable object ­s class. If the current method ­s exception table contains a matching entry, the virtual machine extracts the address of the handler to jump to from the matching exception table entry. The virtual machine pops any words remaining on the operand stack, pushes the objectref , sets the program counter to the handler address, and continues execution there. If the current method ­s exception table doesn ­t have a matching catch clause, the virtual machine pops the current method ­s entire frame and rethrows the exception in the previous method. This process repeats until either a matching catch clause is found or the stack frames for all the methods along the current thread ­s call stack have been popped. If no catch clause is found by this process, the current thread exits.

If the objectref word is null , the virtual machine throws NullPointerException .

For more information about the athrow instruction, see Chapter 17, "Exceptions."

baload

- Load byte or boolean from array

Opcode:

51 (0x33)

Instruction Format:

baload

Stack:

Before: ..., arrayref, index

After: ..., value

Description:

To execute the baload instruction, the Java Virtual Machine first pops two words from the operand stack. The arrayref word must be a reference that refers to an array of byte s or boolean s. The index word must be an int . The virtual machine retrieves from the arrayref array the byte or boolean value specified by index , sign-extends it to an int , and pushes it onto the operand stack.

If arrayref is null , the Java Virtual Machine throws NullPointerException . Otherwise, if index is not a legal index into the arrayref array, the virtual machine throws ArrayIndexOutOfBoundsException .

For more information about the baload instruction, see Chapter 15, "Objects and Arrays."

bastore

- Store into byte or boolean array

Opcode:

84 (0x54)

Instruction Format:

bastore

Stack:

Before: ..., arrayref, index, value

After: ...

Description:

To execute the bastore instruction, the Java Virtual Machine first pops three words from the operand stack. The arrayref word must be a reference that refers to an array of byte s or boolean s. The index and value words must be int s. The virtual machine truncates the int value to a byte and stores it into the arrayref array location specified by index .

If arrayref is null , the Java Virtual Machine throws NullPointerException . Otherwise, if index is not a legal index into the arrayref array, the virtual machine throws ArrayIndexOutOfBoundsException .

For more information about the bastore instruction, see Chapter 15, "Objects and Arrays."

bipush

- Push 8-bit signed integer

Opcode:

16 (0x10)

Instruction Format:

bipush , byte

Stack:

Before:...

After: ..., value

Description:

To execute the bipush instruction, the Java Virtual Machine first sign-extends operand byte , an 8-bit signed integer, to an int . The virtual machine then pushes the resulting int value onto the operand stack.

For more information about the bipush instruction, see Chapter 10, "Stack Operations."

caload

- Load char from array

Opcode:

52 (0x34)

Instruction Format:

caload

Stack:

Before: ..., arrayref, index

After: ..., value

Description:

To execute the caload instruction, the Java Virtual Machine first pops two words from the operand stack. The arrayref word must be a reference that refers to an array of char s. The index word must be an int . The virtual machine retrieves from the arrayref array the char value specified by index , zero-extends it to an int , and pushes it onto the operand stack.

If arrayref is null , the Java Virtual Machine throws NullPointerException . Otherwise, if index is not a legal index into the arrayref array, the virtual machine throws ArrayIndexOutOfBoundsException .

For more information about the caload instruction, see Chapter 15, "Objects and Arrays."

castore

- Store into char array

Opcode:

85 (0x55)

Instruction Format:

castore

Stack:

Before: ..., arrayref, index, value

After: ...

Description:

To execute the castore instruction, the Java Virtual Machine first pops three words from the operand stack. The arrayref word must be a reference that refers to an array of char s. The index and value words must be int s. The virtual machine truncates the int value to a char and stores it into the arrayref array location specified by index .

If arrayref is null , the Java Virtual Machine throws NullPointerException . Otherwise, if index is not a legal index into the arrayref array, the virtual machine throws ArrayIndexOutOfBoundsException .

For more information about the castore instruction, see Chapter 15, "Objects and Arrays."

checkcast

- Make sure object is of given type

Opcode:

192 (0xc0)

Instruction Format:

checkcast , indexbyte1 , indexbyte2

Stack:

Before: ..., objectref

After: ..., objectref

Description:

The top word of the stack, objectref , must be a reference . To execute the checkcast instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the constant pool by calculating (indexbyte1 8) | indexbyte2 .

The virtual machine then looks up the constant pool entry specified by the calculated index. The constant pool entry at that index must be a CONSTANT_Class_info entry. If it hasn ­t already, the virtual machine resolves the entry. The entry may be a class, interface, or array type. If objectref is null or if objectref can be cast to the resolved type, the stack remains unchanged. Otherwise, the virtual machine throws ClassCastException .

To determine whether the object pointed to by objectref can be cast to the resolved type, the virtual machine first determines whether the object is a class instance or array. (It can ­t be an interface instance, because interfaces can ­t be instantiated .) If it is a class instance, and the resolved type is a class, not an interface, the object can be cast to the resolved class if the object ­s class is the resolved class or a subclass of the resolved class. Else, if it is a class instance, and the resolved type is an interface, not an class, the object can be cast to the resolved interface if the object ­s class implements the resolved interface. Otherwise, the object is an array. If the resolved type is a class, it must be java.lang.Object . Else, if the resolved type is an array of primitive types, the object must be an array of the same primitive type. Otherwise, the resolved type must be an array with a component type of some reference type, and the object must be an array with a component type that can be cast to the component type of the resolved array type. (Note that the dimension of an array doesn ­t enter into the checkcast check, only the component type of the array.)

As a result of executing this instruction, the virtual machine may throw any of the linking errors listed in Chapter 8, "The Linking Model," as possible during resolution of a CONSTANT_Class_info entry. If resolution succeeds, but the resolved type cannot be cast to the resolved type, the virtual machine throws an ClassCastException .

For more information about the checkcast instruction, see Chapter 15, "Objects and Arrays."

d2f

- Convert double to float

Opcode:

144 (0x90)

Instruction Format:

d2f

Stack:

Before: ..., value.word1, value.word2

After: ..., result

Description:

The top two words of the operand stack must be a double . To execute the d2f instruction, the Java Virtual Machine pops the double value from the operand stack, converts the double to a float , and pushes the float result .

To convert the double value to float , the Java Virtual Machine first checks to see if the value equals NaN (Not a Number). If so, the float result is also NaN. Else, if the magnitude of the double value is too small to be represented by a float , the float result is a zero of the same sign. Else, if the magnitude of the double value is too large to be represented by a float , the float result is an infinity of the same sign. Otherwise, the virtual machine converts the double value to float zero using IEEE 754 round-to- nearest mode.

Note that this instruction performs a narrowing primitive conversion. Because not all double values are representable by a float , the conversion may result in a loss of magnitude and precision.

For more information about the d2f instruction, see Chapter 11, "Type Conversion."

d2i

- Convert double to int

Opcode:

142 (0x8e)

Instruction Format:

d2i

Stack:

Before: ..., value.word1, value.word2

After: ..., result

Description:

The top two words of the operand stack must be a double . To execute the d2i instruction, the Java Virtual Machine pops the double value from the operand stack, converts the double to an int , and pushes the int result .

To convert the double value to int , the Java Virtual Machine first checks to see if the value equals NaN (Not a Number). If so, the int result is zero. Else, if the double value is not a positive or negative infinity, the virtual machine rounds the value towards zero using IEEE 754 round-towards-zero mode. If the resulting integral value can be exactly represented by an int , the int result is that integral value. Otherwise, the magnitude of the double value is too great be represented in an int . If value is positive, the int result is the largest positive integer representable in an int . If value is negative, the int result is the smallest negative integer representable in an int .

Note that this instruction performs a narrowing primitive conversion. Because not all double values are representable by an int , the conversion may result in a loss of magnitude and precision.

For more information about the d2i instruction, see Chapter 11, "Type Conversion."

d2l

- Convert double to long

Opcode:

143 (0x8f)

Instruction Format:

d2l

Stack:

Before: ..., value.word1, value.word2

After: ..., result.word1, result.word2

Description:

The top two words of the operand stack must be a double . To execute the d2l instruction, the Java Virtual Machine pops the double value from the operand stack, converts the double to a long , and pushes the long result .

To convert the double value to long , the Java Virtual Machine first checks to see if the value equals NaN (Not a Number). If so, the long result is zero. Else, if the double value is not a positive or negative infinity, the virtual machine rounds the value towards zero using IEEE 754 round-towards-zero mode. If the resulting integral value can be exactly represented by a long , the long result is that integral value. Otherwise, the magnitude of the double value is too great be represented in a long . If value is positive, the long result is the largest positive integer representable in a long . If value is negative, the long result is the smallest negative integer representable in an long .

Note that this instruction performs a narrowing primitive conversion. Because not all double values are representable by a long , the conversion may result in a loss of magnitude and precision.

For more information about the d2l instruction, see Chapter 11, "Type Conversion."

dadd

- Add double s

Opcode:

99 (0x63)

Instruction Format:

dadd

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result.word1, result.word2

Description:

The top four words of the operand stack must be two double s, value1 and value2 . To execute the dadd instruction, the Java Virtual Machine pops value1 and value2 , adds them, and pushes the double result . The result produced by the dadd instruction is governed by the rules of IEEE 754 floating point arithmetic.

For more information about the dadd instruction, see Chapter 14, "Floating Point Arithmetic."

daload

- Load double from array

Opcode:

49 (0x31)

Instruction Format:

daload

Stack:

Before: ..., arrayref, index

After: ..., value.word1, value.word2

Description:

To execute the daload instruction, the Java Virtual Machine first pops two words from the operand stack. The arrayref word must be a reference that refers to an array of double s. The index word must be an int . The virtual machine retrieves from the arrayref array the double value specified by index and pushes it onto the operand stack.

If arrayref is null , the Java Virtual Machine throws NullPointerException . Otherwise, if index is not a legal index into the arrayref array, the virtual machine throws ArrayIndexOutOfBoundsException .

For more information about the daload instruction, see Chapter 15, "Objects and Arrays."

dastore

- Store into double array

Opcode:

82 (0x52)

Instruction Format:

dastore

Stack:

Before: ..., arrayref, index, value.word1, value.word2

After: ...

Description:

To execute the daload instruction, the Java Virtual Machine first pops four words from the operand stack. The arrayref word must be a reference that refers to an array of double s. The index word must be an int , and the value words must be a double . The virtual machine stores double value into the arrayref array location specified by index .

If arrayref is null , the Java Virtual Machine throws NullPointerException . Otherwise, if index is not a legal index into the arrayref array, the virtual machine throws ArrayIndexOutOfBoundsException .

For more information about the dastore instruction, see Chapter 15, "Objects and Arrays."

dcmpg

- Compare double s (1 on NaN)

Opcode:

152 (0x98)

Instruction Format:

dcmpg

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result

Description:

The top four words of the operand stack must be two double s, value1 and value2 . To execute the dcmpg instruction, the Java Virtual Machine pops value1 and value2 off the operand stack and compares one against the other. If value1 equals value2 , the virtual machine pushes onto the operand stack int result zero. Else, if value1 is greater than value2 , the virtual machine pushes onto the operand stack int result one. Otherwise, if value1 is less than value2 , the virtual machine pushes onto the operand stack int result negative one. If either value1 or value2 equals NaN (Not a Number), the virtual machine pushes onto the operand stack int result one.

The result produced by the fcmpg instruction is governed by the rules of IEEE 754 floating point arithmetic. Note that the dcmpg instruction differs from the the dcmpl instruction only in its treatment of NaN. For more information about the dcmpg instruction, see Chapter 16, "Control Flow."

dcmpl

- Compare double s (-1 on NaN)

Opcode:

151 (0x97)

Instruction Format:

dcmpl

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result

Description:

The top four words of the operand stack must be two double s, value1 and value2 . To execute the dcmpg instruction, the Java Virtual Machine pops value1 and value2 off the operand stack and compares one against the other. If value1 equals value2 , the virtual machine pushes onto the operand stack int result zero. Else, if value1 is greater than value2 , the virtual machine pushes onto the operand stack int result one. Otherwise, if value1 is less than value2 , the virtual machine pushes onto the operand stack int result negative one. If either value1 or value2 equals NaN (Not a Number), the virtual machine pushes onto the operand stack int result negative one.

The result produced by the fcmpl instruction is governed by the rules of IEEE 754 floating point arithmetic. Note that the dcmpl instruction differs from the the dcmpg instruction only in its treatment of NaN. For more information about the dcmpl instruction, see Chapter 16, "Control Flow."

dconst_0

- Push double constant 0.0

Opcode:

14 (0xe)

Instruction Format:

dconst_0

Stack:

Before: ...

After: ..., <0.0-word1, <0.0-word2

Description:

To execute the dconst_0 instruction, the Java Virtual Machine pushes the double constant 0.0 onto the operand stack.

For more information about the dconst_0 instruction, see Chapter 10, "Stack Operations."

dconst_1

- Push double constant 1.0

Opcode:

15 (0xf)

Instruction Format:

dconst_1

Stack:

Before: ...

After: ..., <1.0-word1, <1.0-word2

Description:

To execute the dconst_1 instruction, the Java Virtual Machine pushes the double constant 1.0 onto the operand stack.

For more information about the dconst_1 instruction, see Chapter 10, "Stack Operations."

ddiv

- Divide double s

Opcode:

111 (0x6f)

Instruction Format:

ddiv

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result.word1, result.word2

Description:

The top four words of the operand stack must be two double s, value1 and value2 . To execute the ddiv instruction, the Java Virtual Machine pops value1 and value2 , divides value1 by value2 ( value1 / value2 ), and pushes the double result . The result produced by the ddiv instruction is governed by the rules of IEEE 754 floating point arithmetic.

For more information about the ddiv instruction, see Chapter 14, "Floating Point Arithmetic."

dload

- Load double from local variable

Opcode:

24 (0x18)

Instruction Format:

dload , index

Stack:

Before:...

After: ..., value.word1, value.word2

Description:

The index operand, which serves as an 8-bit unsigned index into the local variables of the current frame, must specify the first of two consecutive local variable words that contain a double . To execute the dload instruction, the Java Virtual Machine pushes onto the operand stack the double contained in the two consecutive local variable words specified by index and index + 1 .

Note that the wide instruction can precede the lload instruction, to allow a local variable to be accessed with a 16-bit unsigned offset.

For more information about the dload instruction, see Chapter 10, "Stack Operations."

dload_0

- Load double from local variable 0

Opcode:

38 (0x26)

Instruction Format:

dload_0

Stack:

Before: ...

After: ..., value.word1, value.word2

Description:

The two consecutive local variable words at indexes zero and one must contain a double . To execute the dload_0 instruction, the Java Virtual Machine pushes onto the operand stack the double value contained in local variable words zero and one.

For more information about the dload_0 instruction, see Chapter 10, "Stack Operations."

dload_1

- Load double from local variable 1

Opcode:

39 (0x27)

Instruction Format:

dload_1

Stack:

Before: ...

After: ..., value.word1, value.word2

Description:

The two consecutive local variable words at indexes one and two must contain a double . To execute the dload_1 instruction, the Java Virtual Machine pushes onto the operand stack the double value contained in local variable words one and two.

For more information about the dload_1 instruction, see Chapter 10, "Stack Operations."

dload_2

- Load double from local variable 2

Opcode:

40 (0x28)

Instruction Format:

dload_2

Stack:

Before: ...

After: ..., value.word1, value.word2

Description:

The two consecutive local variable words at indexes two and three must contain a double . To execute the dload_2 instruction, the Java Virtual Machine pushes onto the operand stack the double value contained in local variable words two and three.

For more information about the dload_2 instruction, see Chapter 10, "Stack Operations."

dload_3

- Load double from local variable 3

Opcode:

41 (0x29)

Instruction Format:

dload_3

Stack:

Before: ...

After: ..., value.word1, value.word2

Description:

The two consecutive local variable words at indexes three and four must contain a double . To execute the dload_3 instruction, the Java Virtual Machine pushes onto the operand stack the double value contained in local variable words three and four.

For more information about the dload_3 instruction, see Chapter 10, "Stack Operations."

dmul

- Multiply double s

Opcode:

107 (0x6b)

Instruction Format:

dmul

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result.word1, result.word2

Description:

The top four words of the operand stack must be two double s, value1 and value2 . To execute the dmul instruction, the Java Virtual Machine pops value1 and value2 , multiplies them, and pushes the double result . The result produced by the dmul instruction is governed by the rules of IEEE 754 floating point arithmetic.

For more information about the dmul instruction, see Chapter 14, "Floating Point Arithmetic."

dneg

- Negate double

Opcode:

119 (0x77)

Instruction Format:

dneg

Stack:

Before: ..., value.word1, value.word2

After: ..., result.word1, result.word2

Description:

The top two words of the operand stack must be a double . To execute the dneg instruction, the Java Virtual Machine pops value , negates it, and pushes the double result . The result produced by the dneg instruction is governed by the rules of IEEE 754 floating point arithmetic.

Note that the result produced by a dneg instruction is not always the same as the number that would be produced by subtracting value from zero with the dsub instruction. The range of IEEE 754 floating point numbers includes two zeros, a positive zero and a negative zero. When value is +0.0, the result of the dneg instruction is -0.0. By contrast, when subtracting +0.0 from +0.0, the dsub instruction yields +0.0.

For more information about the dneg instruction, see Chapter 14, "Floating Point Arithmetic."

drem

- Calculate remainder of division of double s

Opcode:

115 (0x73)

Instruction Format:

drem

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result.word1, result.word2

Description:

The top four words of the operand stack must be two double s, value1 and value2 . To execute the drem instruction, the Java Virtual Machine pops value1 and value2 , calculates the remainder, and pushes the double result . The remainder equals value1 - (value1 / value2) * value2 , where value1 / value2 is a truncating division, rather than the rounding division required by IEEE 754.

The behavior of drem is comparable to that of the C library function fmod() .The remainder of two double s can be calculated according to IEEE 754 floating point standard via the IEEERemainder() method of class java.lang.Math .

For more information about the drem instruction, see Chapter 14, "Floating Point Arithmetic."

dreturn

- Return double from method

Opcode:

175 (0xaf)

Instruction Format:

dreturn

Stack:

Before: ..., value.word1, value.word2

After: [empty]

Description:

The return type of the returning method must be double . The top two words of the operand stack must be a double . To execute the dreturn instruction, the Java Virtual Machine pops double value from the operand stack of the current frame and pushes it onto the operand stack of the invoking method ­s frame. The virtual machine discards any other words that may still be on the returning method ­s frame. If the returning method is synchronized, the monitor that was acquired when the method was invoked is released. The invoking method ­s frame is made current, and the virtual machine continues execution in the invoking method.

For more information about monitors, see Chapter 20, "Thread Synchronization." For more information about the dreturn instruction, see Chapter 19, "Method Invocation and Return."

dstore

- Store double into local variable

Opcode:

57 (0x39)

Instruction Format:

dstore , index

Stack:

Before:..., value.word1, value.word2

After: ...

Description:

The index operand must specify a valid 8-bit unsigned index into the local variables of the current frame. The top two words of the operand stack must be a double . To execute the dstore instruction, the Java Virtual Machine pops the double value from the top of the operand stack and stores it into the two consecutive local variable words at indexes index and index + 1 .

Note that the wide instruction can precede the dstore instruction, to enable a value to be stored into a local variable specified by a 16-bit unsigned offset.

For more information about the dstore instruction, see Chapter 10, "Stack Operations."

dstore_0

- Store double into local variable 0

Opcode:

71 (0x47)

Instruction Format:

dstore_0

Stack:

Before: ..., value.word1, value.word2

After: ...

Description:

The indexes zero and one must be valid indexes into the local variables of the current stack frame. The top two words on the operand stack must be a double . To execute the dstore_0 instruction, the Java Virtual Machine pops the double value from the top of the operand stack and stores it into the two consecutive local variable words at indexes zero and one.

For more information about the dstore_0 instruction, see Chapter 10, "Stack Operations."

dstore_1

- Store double into local variable 1

Opcode:

72 (0x48)

Instruction Format:

dstore_1

Stack:

Before: ..., value.word1, value.word2

After: ...

Description:

The indexes one and two must be valid indexes into the local variables of the current stack frame. The top two words on the operand stack must be a double . To execute the dstore_1 instruction, the Java Virtual Machine pops the double value from the top of the operand stack and stores it into the two consecutive local variable words at indexes one and two.

For more information about the dstore_1 instruction, see Chapter 10, "Stack Operations."

dstore_2

- Store double into local variable 2

Opcode:

73 (0x49)

Instruction Format:

dstore_2

Stack:

Before: ..., value.word1, value.word2

After: ...

Description:

The indexes two and three must be valid indexes into the local variables of the current stack frame. The top two words on the operand stack must be a double . To execute the dstore_2 instruction, the Java Virtual Machine pops the double value from the top of the operand stack and stores it into the two consecutive local variable words at indexes two and three.

For more information about the dstore_2 instruction, see Chapter 10, "Stack Operations."

dstore_3

- Store double into local variable 3

Opcode:

74 (0x4a)

Instruction Format:

dstore_3

Stack:

Before: ..., value.word1, value.word2

After: ...

Description:

The indexes three and four must be valid indexes into the local variables of the current stack frame. The top two words on the operand stack must be a double . To execute the dstore_3 instruction, the Java Virtual Machine pops the double value from the top of the operand stack and stores it into the two consecutive local variable words at indexes three and four.

For more information about the dstore_3 instruction, see Chapter 10, "Stack Operations."

dsub

- Subtract double s

Opcode:

103 (0x67)

Instruction Format:

dsub

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result.word1, result.word2

Description:

The top four words of the operand stack must be two double s, value1 and value2 . To execute the dsub instruction, the Java Virtual Machine pops value1 and value2 , subtracts value2 from value1 ( value1 - value2 ), and pushes the double result . The result produced by the dsub instruction is governed by the rules of IEEE 754 floating point arithmetic.

For more information about the dsub instruction, see Chapter 14, "Floating Point Arithmetic."

dup

- Duplicate top stack word

Opcode:

89 (0x59)

Instruction Format:

dup

Stack:

Before: ..., word

After: ..., word, word

Description:

To execute the dup instruction, the Java Virtual Machine duplicates the top word of the operand stack and pushes the duplicate. This instruction can be used to duplicate any single-word value from the top of the operand stack. It must not be used to duplicate half of a dual word value ( long or double ) that occupies the top of the operand stack.

For more information about the dup instruction, see Chapter 10, "Stack Operations."

dup_x1

- Duplicate top stack word and put two down

Opcode:

90 (0x5a)

Instruction Format:

dup_x1

Stack:

Before: ..., word2, word1

After: ..., word1, word2, word1

Description:

To execute the dup_x1 instruction, the Java Virtual Machine duplicates the top word of the operand stack and inserts the duplicate two words down. Both word1 and word2 must be single-word values.

For more information about the dup_x1 instruction, see Chapter 10, "Stack Operations."

dup_x2

- Duplicate top stack word and put three down

Opcode:

91 (0x5b)

Instruction Format:

dup_x2

Stack:

Before: ..., word3, word2, word1

After: ..., word1, word3, word2, word1

Description:

To execute the dup_x2 instruction, the Java Virtual Machine duplicates the top word of the operand stack and inserts the duplicate three words down. word1 must be a single-word value. Both word2 and word3 must be single-word values, or together constitute one dual-word value (a long or double ).

For more information about the dup_x2 instruction, see Chapter 10, "Stack Operations."

dup2

- Duplicate top two stack words

Opcode:

92 (0x5c)

Instruction Format:

dup2

Stack:

Before: ..., word2, word1

After: ..., word2, word1, word2, word1

Description:

To execute the dup2 instruction, the Java Virtual Machine duplicates the top two words of the operand stack and pushes the duplicate. This instruction may be used to duplicate any dual-word value or any two single-word values that occupy the top of the operand stack. It must not be used if one single-word value and half of a dual-word value ( long or double ) occupies the top of the operand stack.

For more information about the dup2 instruction, see Chapter 10, "Stack Operations."

dup2_x1

- Duplicate top two stack words and put three down

Opcode:

93 (0x5d)

Instruction Format:

dup2_x1

Stack:

Before: ..., word3, word2, word1

After: ..., word2, word1, word3, word2, word1

Description:

To execute the dup2_x1 instruction, the Java Virtual Machine duplicates the top two words of the operand stack and inserts the duplicate three words down. word3 must be a single-word value. Both word1 and word2 must be single-word values, or together constitute one dual-word value (a long or double ).

For more information about the dup2_x1 instruction, see Chapter 10, "Stack Operations."

dup2_x2

- Duplicate top two stack words and put four down

Opcode:

94 (0x5e)

Instruction Format:

dup2_x2

Stack:

Before: ..., word4, word3, word2, word1

After: ..., word2, word1, word4, word3, word2, word1

Description:

To execute the dup2_x2 instruction, the Java Virtual Machine duplicates the top two words of the operand stack and inserts the duplicate four words down. word3 must be a single-word value. Both word1 and word2 must be single-word values, or together constitute one dual-word value (a long or double ). Likewise, both word3 and word4 must be single-word values, or together constitute one dual-word value.

For more information about the dup2_x2 instruction, see Chapter 10, "Stack Operations."

f2d

- Convert float to double

Opcode:

141 (0x8d)

Instruction Format:

f2d

Stack:

Before: ..., value

After: ..., result.word1, result.word2

Description:

The top word of the operand stack, value , must be a float . To execute the f2d instruction, the Java Virtual Machine pops float value from the operand stack, converts the float to a double , and pushes the double result .

Note that this instruction performs a widening primitive conversion. Because all float values are representable by a double , the conversion is exact.

For more information about the f2d instruction, see Chapter 11, "Type Conversion."

f2i

- Convert float to int

Opcode:

139 (0x8b)

Instruction Format:

f2i

Stack:

Before: ..., value

After: ..., result

Description:

The top word of the operand stack, value , must be a float . To execute the f2i instruction, the Java Virtual Machine pops the float value from the operand stack, converts the float to an int , and pushes the int result .

To convert the float value to int , the Java Virtual Machine first checks to see if the value equals NaN (Not a Number). If so, the int result is zero. Else, if the float value is not a positive or negative infinity, the virtual machine rounds the value towards zero using IEEE 754 round-towards-zero mode. If the resulting integral value can be exactly represented by an int , the int result is that integral value. Otherwise, the magnitude of the float value is too great be represented in an int . If value is positive, the int result is the largest positive integer representable in an int . If value is negative, the int result is the smallest negative integer representable in an int .

Note that this instruction performs a narrowing primitive conversion. Because not all float values are representable by an int , the conversion may result in a loss of magnitude and precision.

For more information about the f2i instruction, see Chapter 11, "Type Conversion."

f2l

- Convert float to long

Opcode:

140 (0x8c)

Instruction Format:

f2l

Stack:

Before: ..., value

After: ..., result.word1, result.word2

Description:

The top word of the operand stack, value , must be a float . To execute the f2l instruction, the Java Virtual Machine pops the float value from the operand stack, converts the float to a long , and pushes the long result .

To convert the float value to long , the Java Virtual Machine first checks to see if the value equals NaN (Not a Number). If so, the long result is zero. Else, if the float value is not a positive or negative infinity, the virtual machine rounds the value towards zero using IEEE 754 round-towards-zero mode. If the resulting integral value can be exactly represented by a long , the long result is that integral value. Otherwise, the magnitude of the float value is too great be represented in a long . If value is positive, the long result is the largest positive integer representable in a long . If value is negative, the int result is the smallest negative integer representable in a long .

Note that this instruction performs a narrowing primitive conversion. Because not all float values are representable by a long , the conversion may result in a loss of magnitude and precision.

For more information about the f2l instruction, see Chapter 11, "Type Conversion."

fadd

- Add float s

Opcode:

98 (0x62)

Instruction Format:

fadd

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be float s. To execute the fadd instruction, the Java Virtual Machine pops value1 and value2 , adds them, and pushes the float result . The result produced by the fadd instruction is governed by the rules of IEEE 754 floating point arithmetic.

For more information about the fadd instruction, see Chapter 14, "Floating Point Arithmetic."

faload

- Load float from array

Opcode:

48 (0x30)

Instruction Format:

faload

Stack:

Before: ..., arrayref, index

After: ..., value

Description:

To execute the faload instruction, the Java Virtual Machine first pops two words from the operand stack. The arrayref word must be a reference that refers to an array of float s. The index word must be an int . The virtual machine retrieves from the arrayref array the float value specified by index and pushes it onto the operand stack.

If arrayref is null , the Java Virtual Machine throws NullPointerException . Otherwise, if index is not a legal index into the arrayref array, the virtual machine throws ArrayIndexOutOfBoundsException .

For more information about the faload instruction, see Chapter 15, "Objects and Arrays."

fastore

- Store into float array

Opcode:

81 (0x51)

Instruction Format:

fastore

Stack:

Before: ..., arrayref, index, value

After: ...

Description:

To execute the faload instruction, the Java Virtual Machine first pops three words from the operand stack. The arrayref word must be a reference that refers to an array of float s. The index word must be an int , and the value word must be a float . The virtual machine stores float value into the arrayref array location specified by index .

If arrayref is null , the Java Virtual Machine throws NullPointerException . Otherwise, if index is not a legal index into the arrayref array, the virtual machine throws ArrayIndexOutOfBoundsException .

For more information about the fastore instruction, see Chapter 15, "Objects and Arrays."

fcmpg

- Compare float s (1 on NaN)

Opcode:

150 (0x96)

Instruction Format:

fcmpg

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be two float s. To execute the fcmpg instruction, the Java Virtual Machine pops value1 and value2 off the operand stack and compares one against the other. If value1 equals value2 , the virtual machine pushes onto the operand stack int result zero. Else, if value1 is greater than value2 , the virtual machine pushes onto the operand stack int result one. Otherwise, if value1 is less than value2 , the virtual machine pushes onto the operand stack int result negative one. If either value1 or value2 equals NaN (Not a Number), the virtual machine pushes onto the operand stack int result one.

The result produced by the fcmpg instruction is governed by the rules of IEEE 754 floating point arithmetic. Note that the fcmpg instruction differs from the the fcmpl instruction only in its treatment of NaN. For more information about the fcmpg instruction, see Chapter 16, "Control Flow."

fcmpl

- Compare float s (-1 on NaN)

Opcode:

149 (0x95)

Instruction Format:

fcmpl

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be two float s. To execute the fcmpl instruction, the Java Virtual Machine pops value1 and value2 off the operand stack and compares one against the other. If value1 equals value2 , the virtual machine pushes onto the operand stack int result zero. Else, if value1 is greater than value2 , the virtual machine pushes onto the operand stack int result one. Otherwise, if value1 is less than value2 , the virtual machine pushes onto the operand stack int result negative one. If either value1 or value2 equals NaN (Not a Number), the virtual machine pushes onto the operand stack int result negative one.

The result produced by the fcmpl instruction is governed by the rules of IEEE 754 floating point arithmetic. Note that the fcmpl instruction differs from the the fcmpg instruction only in its treatment of NaN. For more information about the fcmpl instruction, see Chapter 16, "Control Flow."

fconst_0

- Push float constant 0.0

Opcode:

11 (0xb)

Instruction Format:

fconst_0

Stack:

Before: ...

After: ..., <0.0

Description:

To execute the fconst_0 instruction, the Java Virtual Machine pushes the float constant 0.0 onto the operand stack.

For more information about the fconst_0 instruction, see Chapter 10, "Stack Operations."

fconst_1

- Push float constant 1.0

Opcode:

12 (0xc)

Instruction Format:

fconst_1

Stack:

Before: ...

After: ..., <1.0

Description:

To execute the fconst_1 instruction, the Java Virtual Machine pushes the float constant 1.0 onto the operand stack.

For more information about the fconst_1 instruction, see Chapter 10, "Stack Operations."

fconst_2

- Push float constant 2.0

Opcode:

13 (0xd)

Instruction Format:

fconst_2

Stack:

Before: ...

After: ..., <2.0

Description:

To execute the fconst_2 instruction, the Java Virtual Machine pushes the float constant 2.0 onto the operand stack.

For more information about the fconst_2 instruction, see Chapter 10, "Stack Operations."

fdiv

- Divide float s

Opcode:

110 (0x6e)

Instruction Format:

fdiv

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be float s. To execute the fdiv instruction, the Java Virtual Machine pops value1 and value2 , divides value1 by value2 ( value1 / value2 ), and pushes the float result . The result produced by the fdiv instruction is governed by the rules of IEEE 754 floating point arithmetic.

For more information about the fdiv instruction, see Chapter 14, "Floating Point Arithmetic."

fload

- Load float from local variable

Opcode:

23 (0x17)

Instruction Format:

fload , index

Stack:

Before:...

After: ..., value

Description:

The index operand, which serves as an 8-bit unsigned index into the local variables of the current frame, must specify a local variable word that contains an float . To execute the fload instruction, the Java Virtual Machine pushes onto the operand stack the float contained in the local variable word specified by index .

Note that the wide instruction can precede the fload instruction, to allow a local variable to be accessed with a 16-bit unsigned offset.

For more information about the fload instruction, see Chapter 10, "Stack Operations."

fload_0

- Load float from local variable 0

Opcode:

34 (0x22)

Instruction Format:

fload_0

Stack:

Before: ...

After: ..., value

Description:

The local variable word at index zero must contain a float . To execute the fload_0 instruction, the Java Virtual Machine pushes onto the operand stack the float value contained in local variable word zero.

For more information about the fload_0 instruction, see Chapter 10, "Stack Operations."

fload_1

- Load float from local variable 1

Opcode:

35 (0x23)

Instruction Format:

fload_1

Stack:

Before: ...

After: ..., value

Description:

The local variable word at index one must contain a float . To execute the fload_1 instruction, the Java Virtual Machine pushes onto the operand stack the float value contained in local variable word one.

For more information about the fload_1 instruction, see Chapter 10, "Stack Operations."

fload_2

- Load float from local variable 2

Opcode:

36 (0x24)

Instruction Format:

fload_2

Stack:

Before: ...

After: ..., value

Description:

The local variable word at index two must contain a float . To execute the fload_2 instruction, the Java Virtual Machine pushes onto the operand stack the float value contained in local variable word two.

For more information about the fload_2 instruction, see Chapter 10, "Stack Operations."

fload_3

- Load float from local variable 3

Opcode:

37 (0x25)

Instruction Format:

fload_3

Stack:

Before: ...

After: ..., value

Description:

The local variable word at index three must contain a float . To execute the fload_3 instruction, the Java Virtual Machine pushes onto the operand stack the float value contained in local variable word three.

For more information about the fload_3 instruction, see Chapter 10, "Stack Operations."

fmul

- Multiply float s

Opcode:

106 (0x6a)

Instruction Format:

fmul

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be float s. To execute the fmul instruction, the Java Virtual Machine pops value1 and value2 , multiplies them, and pushes the float result . The result produced by the fmul instruction is governed by the rules of IEEE 754 floating point arithmetic.

For more information about the fmul instruction, see Chapter 14, "Floating Point Arithmetic."

fneg

- Negate float

Opcode:

118 (0x76)

Instruction Format:

fneg

Stack:

Before: ..., value

After: ..., result

Description:

The top word of the operand stack, value , must be a float . To execute the fneg instruction, the Java Virtual Machine pops value , negates it, and pushes the float result . The result produced by the fneg instruction is governed by the rules of IEEE 754 floating point arithmetic.

Note that the result produced by an fneg instruction is not always the same as the number that would be produced by subtracting value from zero with the fsub instruction. The range of IEEE 754 floating point numbers includes two zeros, a positive zero and a negative zero. When value is +0.0, the result of the fneg instruction is -0.0. By contrast, when subtracting +0.0 from +0.0, the fsub instruction yields +0.0.

For more information about the fneg instruction, see Chapter 14, "Floating Point Arithmetic."

frem

- Calculate remainder of division of float s

Opcode:

114 (0x72)

Instruction Format:

frem

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be float s. To execute the frem instruction, the Java Virtual Machine pops value1 and value2 , calculates the remainder, and pushes the float result . The remainder equals value1 - (value1 / value2) * value2 , where value1 / value2 is a truncating division, rather than the rounding division required by IEEE 754.

The behavior of frem is comparable to that of the C library function fmod() .The remainder of two float s can be calculated according to IEEE 754 floating point standard via the IEEERemainder() method of class java.lang.Math .

For more information about the frem instruction, see Chapter 14, "Floating Point Arithmetic."

freturn

- Return float from method

Opcode:

174 (0xae)

Instruction Format:

freturn

Stack:

Before: ..., value

After: [empty]

Description:

The return type of the returning method must be float . The top word of the operand stack, value , must be a float . To execute the freturn instruction, the Java Virtual Machine pops float value from the operand stack of the current frame and pushes it onto the operand stack of the invoking method ­s frame. The virtual machine discards any other words that may still be on the returning method ­s frame. If the returning method is synchronized, the monitor that was acquired when the method was invoked is released. The invoking method ­s frame is made current, and the virtual machine continues execution in the invoking method.

For more information about monitors, see Chapter 20, "Thread Synchronization." For more information about the freturn instruction, see Chapter 19, "Method Invocation and Return."

fstore

- Store float into local variable

Opcode:

56 (0x38)

Instruction Format:

fstore , index

Stack:

Before:..., value

After: ...

Description:

The index operand must specify a valid 8-bit unsigned index into the local variables of the current frame. The value on the top of the operand stack must be a float . To execute the fstore instruction, the Java Virtual Machine pops the float value from the top of the operand stack and stores it into the local variable word specified by index .

Note that the wide instruction can precede the fstore instruction, to enable a value to be stored into a local variable specified by a 16-bit unsigned offset.

For more information about the fstore instruction, see Chapter 10, "Stack Operations."

fstore_0

- Store float into local variable 0

Opcode:

67 (0x43)

Instruction Format:

fstore_0

Stack:

Before: ..., value

After: ...

Description:

The index zero must be a valid index into the local variables of the current stack frame, and the value word on the top of the operand stack must be a float . To execute the fstore_0 instruction, the Java Virtual Machine pops the float value from the top of the operand stack and stores it into the local variable word at index zero.

For more information about the fstore_0 instruction, see Chapter 10, "Stack Operations."

fstore_1

- Store float into local variable 1

Opcode:

68 (0x44)

Instruction Format:

fstore_1

Stack:

Before: ..., value

After: ...

Description:

The index one must be a valid index into the local variables of the current stack frame, and the value word on the top of the operand stack must be a float . To execute the fstore_1 instruction, the Java Virtual Machine pops the float value from the top of the operand stack and stores it into the local variable word at index one.

For more information about the fstore_1 instruction, see Chapter 10, "Stack Operations."

fstore_2

- Store float into local variable 2

Opcode:

69 (0x45)

Instruction Format:

fstore_2

Stack:

Before: ..., value

After: ...

Description:

The index two must be a valid index into the local variables of the current stack frame, and the value word on the top of the operand stack must be a float . To execute the fstore_2 instruction, the Java Virtual Machine pops the float value from the top of the operand stack and stores it into the local variable word at index two.

For more information about the fstore_2 instruction, see Chapter 10, "Stack Operations."

fstore_3

- Store float into local variable 3

Opcode:

70 (0x46)

Instruction Format:

fstore_3

Stack:

Before: ..., value

After: ...

Description:

The index three must be a valid index into the local variables of the current stack frame, and the value word on the top of the operand stack must be a float . To execute the fstore_3 instruction, the Java Virtual Machine pops the float value from the top of the operand stack and stores it into the local variable word at index three.

For more information about the fstore_3 instruction, see Chapter 10, "Stack Operations."

fsub

- Subtract float s

Opcode:

102 (0x66)

Instruction Format:

fsub

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be float s. To execute the fsub instruction, the Java Virtual Machine pops value1 and value2 , subtracts value2 from value1 ( value1 - value2 ), and pushes the float result . The result produced by the fsub instruction is governed by the rules of IEEE 754 floating point arithmetic.

For more information about the fsub instruction, see Chapter 14, "Floating Point Arithmetic."

getfield

- Fetch field from object

Opcode:

180 (0xb4)

Instruction Format:

getfield , indexbyte1 , indexbyte2

Stack:

Before:..., objectref

After: ..., value

or

Before: ..., objectref

After: ..., value.word1, value.word2

Description:

The top word of the stack, objectref , must be a reference . To execute the getfield instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the constant pool by calculating (indexbyte1 8) | indexbyte2 .

The virtual machine then looks up the constant pool entry specified by the calculated index. The constant pool entry at that index must be a CONSTANT_Fieldref_info entry. If it hasn ­t already, the virtual machine resolves the entry, which yields the field ­s width and the field ­s offset from the beginning of the object image. If the resolution is successful, the virtual machine pops the objectref and fetches the field from the object pointed to by objectref . If the type of the field is byte , short , or char , the virtual machine sign-extends the field ­s value to an int and pushes the single-word int value onto the operand stack. Else, if the type is int , boolean , float , or reference , the virtual machine pushes the single-word value onto the operand stack. Otherwise, the type is long or double , and the virtual machine pushes the dual-word value onto the operand stack.

As a result of executing this instruction, the virtual machine may throw any of the linking errors listed in Chapter 8, "The Linking Model," as possible during resolution of a CONSTANT_Fieldref_info entry. As part of the process of resolving the CONSTANT_Fieldref_info entry, the virtual machine checks whether the field ­s access permission enables the current class to access the field. If the field is protected, the virtual machine makes certain the field is a member of the either the current class or a superclass of the current class, and that the class of the object pointed to by objectref is either the current class or a subclass of the current class. If not (or if there is any other access permission problem), the virtual machine throws IllegalAccessError . Else, if the field exists and is accessible from the current class, but the field is static, the virtual machine throws IncompatibleClassChangeError . Otherwise, if objectref is null , the virtual machine throws NullPointerException .

For more information about the getfield instruction, see Chapter 15, "Objects and Arrays."

getstatic

- Fetch static field from class

Opcode:

178 (0xb2)

Instruction Format:

getstatic , indexbyte1 , indexbyte2

Stack:

Before:...

After: ..., value

or

Before: ...

After: ..., value.word1, value.word2

Description:

To execute the getstatic instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the constant pool by calculating (indexbyte1 8) | indexbyte2 .

The virtual machine then looks up the constant pool entry specified by the calculated index. The constant pool entry at that index must be a CONSTANT_Fieldref_info entry. If it hasn ­t already, the virtual machine resolves the entry. If the resolution is successful, the virtual machine fetches the value of the static field. If the type of the field is byte , short , or char , the virtual machine sign-extends the field ­s value to int and pushes the single-word int value onto the operand stack. Else, if the type is int , boolean , float , or reference the virtual machine pushes the single-word value onto the operand stack. Otherwise, the type is long or double , and the virtual machine pushes the dual-word value onto the operand stack.

As a result of executing this instruction, the virtual machine may throw any of the linking errors listed in Chapter 8, "The Linking Model," as possible during resolution of a CONSTANT_Fieldref_info entry. As part of the process of resolving the CONSTANT_Fieldref_info entry, the virtual machine checks whether the field ­s access permission enables the current class to access the field. If the field is protected, the virtual machine makes certain the field is a member of the either the current class or a superclass of the current class. If not (or if there is any other access permission problem), the virtual machine throws IllegalAccessError . Else, if the field exists and is accessible from the current class, but the field is not static, the virtual machine throws IncompatibleClassChangeError .

For more information about the getstatic instruction, see Chapter 15, "Objects and Arrays."

goto

- Branch always

Opcode:

167 (0xa7)

Instruction Format:

goto , branchbyte1 , branchbyte2

Stack:

No change

Description:

To execute the goto instruction, the Java Virtual Machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 .

The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the goto opcode. The target address must be the address of an opcode within the same method as the goto opcode. The virtual machine jumps to the target address and continues execution there.

For more information about the goto instruction, see Chapter 16, "Control Flow."

goto_w

- Branch always (wide index)

Opcode:

200 (0xc8)

Instruction Format:

goto_w = 200 , branchbyte1 , branchbyte2 , branchbyte3 , branchbyte4

Stack:

No change

Description:

To execute the goto_w instruction, the Java Virtual Machine forms a signed 32-bit offset by calculating (branchbyte1 24) | (branchbyte2 16) | (branchbyte3 8) | branchbyte4 .

The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the goto_w opcode. The target address must be the address of an opcode within the same method as the goto_w opcode. The virtual machine jumps to the target address and continues execution there.

Note that despite the 32-bit offset of the goto_w instruction, Java methods are currently (in both the 1.0 and 1.1 releases) limited to 65,535 bytes by three items in the Java class file format: the sizes of the indexes in the LineNumberTable attribute, the LocalVariableTable attribute, and the Code attribute ­s exception_table item. According to the Java Virtual Machine specification, the 65,536 byte limit to Java methods may be raised in a future release. For more information about the goto_w instruction, see Chapter 16, "Control Flow."

i2b

- Convert int to byte

Opcode:

145 (0x91)

Instruction Format:

i2b

Stack:

Before: ..., value

After: ..., result

Description:

The top word of the operand stack, value , must be an int . To execute the i2b instruction, the Java Virtual Machine pops int value from the operand stack, truncates the int to a byte , sign-extends the result back to an int , and pushes the int result .

Note that this instruction performs a narrowing primitive conversion. As a result of this conversion, magnitude information may be lost and the sign bit may change.

For more information about the i2b instruction, see Chapter 11, "Type Conversion."

i2c

- Convert int to char

Opcode:

146 (0x92)

Instruction Format:

i2c

Stack:

Before: ..., value

After: ..., result

Description:

The top word of the operand stack, value , must be an int . To execute the i2c instruction, the Java Virtual Machine pops int value from the operand stack, truncates the int to a char , zero-extends the result back to an int , and pushes the int result .

Note that this instruction performs a narrowing primitive conversion. As a result of this conversion, magnitude information may be lost and, as the result is always positive, the sign bit may change.

For more information about the i2c instruction, see Chapter 11, "Type Conversion."

i2d

- Convert int to double

Opcode:

135 (0x87)

Instruction Format:

i2d

Stack:

Before: ..., value

After: ..., result.word1, result.word2

Description:

The top word of the operand stack, value , must be an int . To execute the i2d instruction, the Java Virtual Machine pops int value from the operand stack, sign-extends the int to a double , and pushes the double result .

Note that this instruction performs a widening primitive conversion. Because all int values are representable by a double , the conversion is exact.

For more information about the i2d instruction, see Chapter 11, "Type Conversion."

i2f

- Convert int to float

Opcode:

134 (0x86)

Instruction Format:

i2f

Stack:

Before: ..., value

After: ..., result

Description:

The top word of the operand stack, value , must be an int . To execute the i2f instruction, the Java Virtual Machine pops int value from the operand stack, converts the int to a float using the IEEE round-to-nearest mode, and pushes the float result .

Note that this instruction performs a widening primitive conversion. Because not all int values are exactly representable by a float , the conversion may result in a loss of precision.

For more information about the i2f instruction, see Chapter 11, "Type Conversion."

i2l

- Convert int to long

Opcode:

133 (0x85)

Instruction Format:

i2l

Stack:

Before: ..., value

After: ..., result.word1, result.word2

Description:

The top word of the operand stack, value , must be an int . To execute the i2l instruction, the Java Virtual Machine pops int value from the operand stack, sign-extends the int to a long , and pushes the long result .

Note that this instruction performs a widening primitive conversion. Because all int values are representable by a long , the conversion is exact.

For more information about the i2l instruction, see Chapter 11, "Type Conversion."

i2s

- Convert int to short

Opcode:

147 (0x93)

Instruction Format:

i2s

Stack:

Before: ..., value

After: ..., result

Description:

The top word of the operand stack, value , must be an int . To execute the i2s instruction, the Java Virtual Machine pops int value from the operand stack, truncates the int to a short , sign-extends the result back to an int , and pushes the int result .

Note that this instruction performs a narrowing primitive conversion. As a result of this conversion, magnitude information may be lost and the sign bit may change.

For more information about the i2s instruction, see Chapter 11, "Type Conversion."

iadd

- Add int s

Opcode:

96 (0x60)

Instruction Format:

iadd

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the iadd instruction, the Java Virtual Machine pops value1 and value2 , adds them, and pushes the int result . If overflow occurs, result is the 32 lowest order bits of the true mathematical result represented in a sufficiently wide two ­s-complement format, and the sign of result is different from that of the true mathematical result.

For more information about the iadd instruction, see Chapter 12, "Integer Arithmetic."

iaload

- Load int from array

Opcode:

46 (0x2e)

Instruction Format:

iaload

Stack:

Before: ..., arrayref, index

After: ..., value

Description:

To execute the iaload instruction, the Java Virtual Machine first pops two words from the operand stack. The arrayref word must be a reference that refers to an array of int s. The index word must be an int .

The virtual machine retrieves from the arrayref array the int value specified by index and pushes it onto the operand stack.

If arrayref is null , the Java Virtual Machine throws NullPointerException . Otherwise, if index is not a legal index into the arrayref array,

The virtual machine throws ArrayIndexOutOfBoundsException .

For more information about the iaload instruction, see Chapter 15, "Objects and Arrays."

iand

- Perform boolean AND on int s

Opcode:

126 (0x7e)

Instruction Format:

iand

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the iand instruction, the Java Virtual Machine pops value1 and value2 , bitwise ANDs them, and pushes the int result .

For more information about the iand instruction, see Chapter 13, "Logic."

iastore

- Store into int array

Opcode:

79 (0x4f)

Instruction Format:

iastore

Stack:

Before: ..., arrayref, index, value

After: ...

Description:

To execute the iastore instruction, the Java Virtual Machine first pops three words from the operand stack. The arrayref word must be a reference that refers to an array of int s. The index and value words must be int s.

The virtual machine stores int value into the arrayref array location specified by index .

If arrayref is null , the Java Virtual Machine throws NullPointerException . Otherwise, if index is not a legal index into the arrayref array,

The virtual machine throws ArrayIndexOutOfBoundsException .

For more information about the iastore instruction, see Chapter 15, "Objects and Arrays."

iconst_0

- Push int constant 0

Opcode:

3 (0x3)

Instruction Format:

iconst_0

Stack:

Before: ...

After: ..., 0

Description:

To execute the iconst_0 instruction, the Java Virtual Machine pushes the int constant 0 onto the operand stack.

For more information about the iconst_0 instruction, see Chapter 10, "Stack Operations."

iconst_1

- Push int constant 1

Opcode:

4 (0x4)

Instruction Format:

iconst_1

Stack:

Before: ...

After: ..., 1

Description:

To execute the iconst_1 instruction, the Java Virtual Machine pushes the int constant 1 onto the operand stack.

For more information about the iconst_1 instruction, see Chapter 10, "Stack Operations."

iconst_2

- Push int constant 2

Opcode:

5 (0x5)

Instruction Format:

iconst_2

Stack:

Before: ...

After: ..., 2

Description:

To execute the iconst_2 instruction, the Java Virtual Machine pushes the int constant 2 onto the operand stack.

For more information about the iconst_2 instruction, see Chapter 10, "Stack Operations."

iconst_3

- Push int constant 3

Opcode:

6 (0x6)

Instruction Format:

iconst_3

Stack:

Before: ...

After: ..., 3

Description:

To execute the iconst_3 instruction, the Java Virtual Machine pushes the int constant 3 onto the operand stack.

For more information about the iconst_3 instruction, see Chapter 10, "Stack Operations."

iconst_4

- Push int constant 4

Opcode:

7 (0x7)

Instruction Format:

iconst_4

Stack:

Before: ...

After: ..., 4

Description:

To execute the iconst_4 instruction, the Java Virtual Machine pushes the int constant 4 onto the operand stack.

For more information about the iconst_4 instruction, see Chapter 10, "Stack Operations."

iconst_5

- Push int constant 5

Opcode:

8 (0x8)

Instruction Format:

iconst_5

Stack:

Before: ...

After: ..., 5

Description:

To execute the iconst_5 instruction, the Java Virtual Machine pushes the int constant 5 onto the operand stack.

For more information about the iconst_5 instruction, see Chapter 10, "Stack Operations."

iconst_m1

- Push int constant -1

Opcode:

2 (0x2)

Instruction Format:

iconst_m1

Stack:

Before: ...

After: ..., -1

Description:

To execute the iconst_m1 instruction, the Java Virtual Machine pushes the int constant -1 onto the operand stack.

For more information about the iconst_m1 instruction, see Chapter 10, "Stack Operations."

idiv

- Divide int s

Opcode:

108 (0x6c)

Instruction Format:

idiv

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the idiv instruction, the Java Virtual Machine pops value1 and value2 , integer divides value1 by value2 ( value1 / value2 ), and pushes the int result .

Integer division rounds the magnitude of the true mathematical quotient towards zero to the nearest integer. If the magnitude of the denominator is greater than that of the numerator, the int result is zero. Else, with one special exception, the sign of result is positive if the signs of the numerator and denominator are the same, negative if they are different. The exception to this rule is when the numerator is the smallest negative integer that can be represented by an int and the denominator is -1. For this division, the true mathematical result is one greater than the largest positive integer that can be represented by an int . As a consequence, the division overflows and the result is equal to the numerator.

If value2 (the denominator) is zero, the Java Virtual Machine throws ArithmeticException .

For more information about the idiv instruction, see Chapter 12, "Integer Arithmetic."

ifeq

- Branch if equal to 0

Opcode:

153 (0x99)

Instruction Format:

ifeq , branchbyte1 , branchbyte2

Stack:

Before:..., value

After: ...

Description:

The top word of the operand stack, value , must be an int . To execute the ifeq instruction, the Java Virtual Machine pops value off the operand stack and compares it against zero. If value equals zero,

The virtual machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the ifeq opcode. The target address must be the address of an opcode within the same method as the ifeq opcode. The virtual machine jumps to the target address and continues execution there. Otherwise, if value does not equal zero, The virtual machine does not take the jump. It simply continues execution at the instruction immediately following the ifeq instruction.

For more information about the ifeq instruction, see Chapter 16, "Control Flow."

ifge

- Branch if greater than or equal to 0

Opcode:

156 (0x9c)

Instruction Format:

ifge , branchbyte1 , branchbyte2

Stack:

Before:..., value

After: ...

Description:

The top word of the operand stack, value , must be an int . To execute the ifge instruction, the Java Virtual Machine pops value off the operand stack and compares it against zero. If value is greater than or equal to zero,

The virtual machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the ifge opcode. The target address must be the address of an opcode within the same method as the ifge opcode. The virtual machine jumps to the target address and continues execution there. Otherwise, if value is not greater than or equal to zero, The virtual machine does not take the jump. It simply continues execution at the instruction immediately following the ifge instruction.

For more information about the ifge instruction, see Chapter 16, "Control Flow."

ifgt

- Branch if greater than 0

Opcode:

157 (0x9d)

Instruction Format:

ifgt , branchbyte1 , branchbyte2

Stack:

Before:..., value

After: ...

Description:

The top word of the operand stack, value , must be an int . To execute the ifgt instruction, the Java Virtual Machine pops value off the operand stack and compares it against zero. If value is greater than zero,

The virtual machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the ifgt opcode. The target address must be the address of an opcode within the same method as the ifgt opcode. The virtual machine jumps to the target address and continues execution there. Otherwise, if value is not greater than zero, The virtual machine does not take the jump. It simply continues execution at the instruction immediately following the ifgt instruction.

For more information about the ifgt instruction, see Chapter 16, "Control Flow."

ifle

- Branch if less than or equal to 0

Opcode:

158 (0x9e)

Instruction Format:

ifle , branchbyte1 , branchbyte2

Stack:

Before:..., value

After: ...

Description:

The top word of the operand stack, value , must be an int . To execute the ifle instruction, the Java Virtual Machine pops value off the operand stack and compares it against zero. If value is less than or equal to zero,

The virtual machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the ifle opcode. The target address must be the address of an opcode within the same method as the ifle opcode. The virtual machine jumps to the target address and continues execution there. Otherwise, if value is not less than or equal to zero, The virtual machine does not take the jump. It simply continues execution at the instruction immediately following the ifle instruction.

For more information about the ifle instruction, see Chapter 16, "Control Flow."

iflt

- Branch if less than 0

Opcode:

155 (0x9b)

Instruction Format:

iflt , branchbyte1 , branchbyte2

Stack:

Before:..., value

After: ...

Description:

The top word of the operand stack, value , must be an int . To execute the iflt instruction, the Java Virtual Machine pops value off the operand stack and compares it against zero. If value is less than zero,

The virtual machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the iflt opcode. The target address must be the address of an opcode within the same method as the iflt opcode. The virtual machine jumps to the target address and continues execution there. Otherwise, if value is not less than zero, The virtual machine does not take the jump. It simply continues execution at the instruction immediately following the iflt instruction.

For more information about the iflt instruction, see Chapter 16, "Control Flow."

ifne

- Branch if not equal to 0

Opcode:

154 (0x9a)

Instruction Format:

ifne , branchbyte1 , branchbyte2

Stack:

Before:..., value

After: ...

Description:

The top word of the operand stack, value , must be an int . To execute the ifne instruction, the Java Virtual Machine pops value off the operand stack and compares it against zero. If value does not equal zero,

The virtual machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the ifne opcode. The target address must be the address of an opcode within the same method as the ifne opcode. The virtual machine jumps to the target address and continues execution there. Otherwise, if value does equal zero, The virtual machine does not take the jump. It simply continues execution at the instruction immediately following the ifne instruction.

For more information about the ifne instruction, see Chapter 16, "Control Flow."

ifnonnull

- Branch if not null

Opcode:

199 (0xc7)

Instruction Format:

ifnonnull , branchbyte1 , branchbyte2

Stack:

Before:..., value

After: ...

Description:

The top word of the operand stack, value , must be a reference . To execute the ifnonnull instruction, the Java Virtual Machine pops value off the operand stack and compares it against null . If value is not null ,

The virtual machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the ifnonnull opcode. The target address must be the address of an opcode within the same method as the ifnonnull opcode. The virtual machine jumps to the target address and continues execution there. Otherwise, if value is null , The virtual machine does not take the jump. It simply continues execution at the instruction immediately following the ifnonnull instruction.

For more information about the ifnonnull instruction, see Chapter 16, "Control Flow."

ifnull

- Branch if null

Opcode:

198 (0xc6)

Instruction Format:

ifnull , branchbyte1 , branchbyte2

Stack:

Before:..., value

After: ...

Description:

The top word of the operand stack, value , must be a reference . To execute the ifnull instruction, the Java Virtual Machine pops value off the operand stack and compares it against null . If value is null ,

The virtual machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the ifnull opcode. The target address must be the address of an opcode within the same method as the ifnull opcode. The virtual machine jumps to the target address and continues execution there. Otherwise, if value is not null , The virtual machine does not take the jump. It simply continues execution at the instruction immediately following the ifnull instruction.

For more information about the ifnull instruction, see Chapter 16, "Control Flow."

if_acmpeq

- Branch if object references are equal

Opcode:

165 (0xa5)

Instruction Format:

if_acmpeq , branchbyte1 , branchbyte2

Stack:

Before:..., value1, value2

After: ...

Description:

The top two words of the operand stack, value1 and value2 , must be reference s. To execute the if_acmpeq instruction, the Java Virtual Machine pops value1 and value2 off the operand stack and compares one against the other. If value1 equals value2 (in other words, if they both point to exactly the same object or are both null ),

The virtual machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the if_acmpeq opcode. The target address must be the address of an opcode within the same method as the if_acmpeq opcode. The virtual machine jumps to the target address and continues execution there. Otherwise, if value does not equal value2 , The virtual machine does not take the jump. It simply continues execution at the instruction immediately following the if_acmpeq instruction.

For more information about the if_acmpeq instruction, see Chapter 16, "Control Flow."

if_acmpne

- Branch if object references not equal

Opcode:

166 (0xa6)

Instruction Format:

if_acmpne , branchbyte1 , branchbyte2

Stack:

Before:..., value1, value2

After: ...

Description:

The top two words of the operand stack, value1 and value2 , must be reference s. To execute the if_acmpne instruction, the Java Virtual Machine pops value1 and value2 off the operand stack and compares one against the other. If value1 does not equal value2 (in other words, if they don ­t both point to exactly the same object and they aren ­t both null ),

The virtual machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the if_acmpne opcode. The target address must be the address of an opcode within the same method as the if_acmpne opcode. The virtual machine jumps to the target address and continues execution there. Otherwise, if value equals value2 , The virtual machine does not take the jump. It simply continues execution at the instruction immediately following the if_acmpne instruction.

For more information about the if_acmpne instruction, see Chapter 16, "Control Flow."

if_icmpeq

- Branch if int s equal

Opcode:

159 (0x9f)

Instruction Format:

if_icmpeq , branchbyte1 , branchbyte2

Stack:

Before:..., value1, value2

After: ...

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the if_icmpeq instruction, the Java Virtual Machine pops value1 and value2 off the operand stack and compares one against the other. If value1 equals value2 ,

The virtual machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the if_icmpeq opcode. The target address must be the address of an opcode within the same method as the if_icmpeq opcode. The virtual machine jumps to the target address and continues execution there. Otherwise, if value does not equal value2 , The virtual machine does not take the jump. It simply continues execution at the instruction immediately following the if_icmpeq instruction.

For more information about the if_icmpeq instruction, see Chapter 16, "Control Flow."

if_icmpge

- Branch if int greater than or equal to other int

Opcode:

162 (0xa2)

Instruction Format:

if_icmpge , branchbyte1 , branchbyte2

Stack:

Before:..., value1, value2

After: ...

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the if_icmpge instruction, the Java Virtual Machine pops value1 and value2 off the operand stack and compares one against the other. If value1 is greater than or equal to value2 ,

The virtual machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the if_icmpge opcode. The target address must be the address of an opcode within the same method as the if_icmpge opcode. The virtual machine jumps to the target address and continues execution there. Otherwise, if value is not greater than or equal to value2 , The virtual machine does not take the jump. It simply continues execution at the instruction immediately following the if_icmpge instruction.

For more information about the if_icmpge instruction, see Chapter 16, "Control Flow."

if_icmpgt

- Branch if int greater than other int

Opcode:

163 (0xa3)

Instruction Format:

if_icmpgt , branchbyte1 , branchbyte2

Stack:

Before:..., value1, value2

After: ...

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the if_icmpgt instruction, the Java Virtual Machine pops value1 and value2 off the operand stack and compares one against the other. If value1 is greater than value2 ,

The virtual machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the if_icmpgt opcode. The target address must be the address of an opcode within the same method as the if_icmpgt opcode. The virtual machine jumps to the target address and continues execution there. Otherwise, if value is not greater than value2 , The virtual machine does not take the jump. It simply continues execution at the instruction immediately following the if_icmpgt instruction.

For more information about the if_icmpgt instruction, see Chapter 16, "Control Flow."

if_icmple

- Branch if int less than or equal to other int

Opcode:

164 (0xa4)

Instruction Format:

if_icmple , branchbyte1 , branchbyte2

Stack:

Before:..., value1, value2

After: ...

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the if_icmple instruction, the Java Virtual Machine pops value1 and value2 off the operand stack and compares one against the other. If value1 is less than or equal to value2 ,

The virtual machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the if_icmple opcode. The target address must be the address of an opcode within the same method as the if_icmple opcode. The virtual machine jumps to the target address and continues execution there. Otherwise, if value is not less than or equal to value2 , The virtual machine does not take the jump. It simply continues execution at the instruction immediately following the if_icmple instruction.

For more information about the if_icmple instruction, see Chapter 16, "Control Flow."

if_icmplt

- Branch if int less than other int

Opcode:

161 (0xa1)

Instruction Format:

if_icmplt , branchbyte1 , branchbyte2

Stack:

Before:..., value1, value2

After: ...

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the if_icmplt instruction, the Java Virtual Machine pops value1 and value2 off the operand stack and compares one against the other. If value1 is less than value2 ,

The virtual machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the if_icmplt opcode. The target address must be the address of an opcode within the same method as the if_icmplt opcode. The virtual machine jumps to the target address and continues execution there. Otherwise, if value is not less than value2 , The virtual machine does not take the jump. It simply continues execution at the instruction immediately following the if_icmplt instruction.

For more information about the if_icmplt instruction, see Chapter 16, "Control Flow."

if_icmpne

- Branch if int s not equal

Opcode:

160 (0xa0)

Instruction Format:

if_icmpne , branchbyte1 , branchbyte2

Stack:

Before:..., value1, value2

After: ...

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the if_icmpne instruction, the Java Virtual Machine pops value1 and value2 off the operand stack and compares one against the other. If value1 does not equal value2 ,

The virtual machine forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the if_icmpne opcode. The target address must be the address of an opcode within the same method as the if_icmpne opcode. The virtual machine jumps to the target address and continues execution there. Otherwise, if value1 equals value2 , The virtual machine does not take the jump. It simply continues execution at the instruction immediately following the if_icmpne instruction.

For more information about the if_icmpne instruction, see Chapter 16, "Control Flow."

iinc

- Increment int local variable by constant

Opcode:

132 (0x84)

Instruction Format:

iinc , index , const

Stack:

No change

Description:

The index operand must specify a valid 8-bit unsigned index into the local variables of the current frame. To execute the iinc instruction, the Java Virtual Machine adds the 8-bit signed increment const to the local variable word specified by index.

Note that the wide instruction can precede the iinc instruction, to enable a local variable specified by a 16-bit unsigned offset to be incremented by a signed 16-bit constant.

For more information about the iinc instruction, see Chapter 12, "Integer Arithmetic."

iload

- Load int from local variable

Opcode:

21 (0x15)

Instruction Format:

iload , index

Stack:

Before:...

After: ..., value

Description:

The index operand, which serves as an 8-bit unsigned index into the local variables of the current frame, must specify a local variable word that contains an int . To execute the iload instruction, the Java Virtual Machine pushes onto the operand stack the int value contained in the local variable word specified by index .

Note that the wide instruction can precede the iload instruction, to allow a local variable to be accessed with a 16-bit unsigned offset.

For more information about the iload instruction, see Chapter 10, "Stack Operations."

iload_0

- Load int from local variable 0

Opcode:

26 (0x1a)

Instruction Format:

iload_0

Stack:

Before: ..

After: ..., value

Description:

The local variable word at index zero must contain an int . To execute the iload_0 instruction, the Java Virtual Machine pushes onto the operand stack the int value contained in the local variable word zero.

For more information about the iload_0 instruction, see Chapter 10, "Stack Operations."

iload_1

- Load int from local variable 1

Opcode:

27 (0x1b)

Instruction Format:

iload_1

Stack:

Before: ..

After: ..., value

Description:

The local variable word at index one must contain an int . To execute the iload_1 instruction, the Java Virtual Machine pushes onto the operand stack the int contained in the local variable word one.

For more information about the iload_1 instruction, see Chapter 10, "Stack Operations."

iload_2

- Load int from local variable 2

Opcode:

28 (0x1c)

Instruction Format:

iload_2

Stack:

Before: ..

After: ..., value

Description:

The local variable word at index two must contain an int . To execute the iload_2 instruction, the Java Virtual Machine pushes onto the operand stack the int value contained in the local variable word two.

For more information about the iload_2 instruction, see Chapter 10, "Stack Operations."

iload_3

- Load int from local variable 3

Opcode:

29 (0x1d)

Instruction Format:

iload_3

Stack:

Before: ..

After: ..., value

Description:

The local variable word at index three must contain an int . To execute the iload_3 instruction, the Java Virtual Machine pushes onto the operand stack the int value contained in the local variable word three.

For more information about the iload_3 instruction, see Chapter 10, "Stack Operations."

imul

- Multiply int s

Opcode:

104 (0x68)

Instruction Format:

imul

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the imul instruction, the Java Virtual Machine pops value1 and value2 , multiplies them, and pushes the int result . If overflow occurs, result is the 32 lowest order bits of the true mathematical result represented in a sufficiently wide two ­s-complement format, and the sign of result may be different from that of the true mathematical result.

For more information about the imul instruction, see Chapter 12, "Integer Arithmetic."

ineg

- Negate int

Opcode:

116 (0x74)

Instruction Format:

ineg

Stack:

Before: ..., value

After: ..., result

Description:

The top word of the operand stack, value , must be an int . To execute the ineg instruction, the Java Virtual Machine pops value , negates it, and pushes the int result .

The result produced by an ineg instruction is the same number that would be produced by subtracting value from zero with the isub instruction. As a consequence, when value is the smallest negative integer that can be represented by an int , the negation overflows. For this negation, the true mathematical result is one greater than the largest positive integer that can be represented by an int , and the actual result is equal to value with no change in sign.

For more information about the ineg instruction, see Chapter 12, "Integer Arithmetic."

instanceof

- Determine if an object is of given type

Opcode:

193 (0xc1)

Instruction Format:

instanceof , indexbyte1 , indexbyte2

Stack:

Before:..., objectref

After: ..., result

Description:

The top word of the stack, objectref , must be a reference . To execute the instanceof instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the constant pool by calculating (indexbyte1 8) | indexbyte2 .

The virtual machine then looks up the constant pool entry specified by the calculated index. The constant pool entry at that index must be a CONSTANT_Class_info entry. If it hasn ­t already, The virtual machine resolves the entry. The entry may be a class, interface, or array type. If objectref is not null and the object pointed to by objectref is an "instance of" the resolved type, The virtual machine pushes an int one result onto the operand stack. Otherwise, The virtual machine machine pushes an int zero result onto the operand stack.

To determine whether the object pointed to by objectref is an "instance of" the resolved type, The virtual machine first determines whether the object is a class instance or array. (It can ­t be an interface instance, because interfaces can ­t be instantiated.) If it is a class instance, and the resolved type is a class, not an interface, the object is "an instance" of the resolved class if the object ­s class is the resolved class or a subclass of the resolved class. Else, if it is a class instance, and the resolved type is an interface, not an class, the object is "an instance" of the resolved interface if the object ­s class implements the resolved interface. Otherwise, the object is an array. If the resolved type is a class, it must be java.lang.Object . Else, if the resolved type is an array of primitive types, the object must be an array of the same primitive type. Otherwise, the resolved type must be an array with a component type of some reference type, and the object must be an array with a component type that is an "instance of" the component type of the resolved array type. (Note that the dimension of an array doesn ­t enter into the instanceof check, only the component type of the array.)

As a result of executing this instruction, The virtual machine may throw any of the linking errors listed in Chapter 8, "The Linking Model," as possible during resolution of a CONSTANT_Class_info entry.

For more information about the instanceof instruction, see Chapter 15, "Objects and Arrays."

invokeinterface

- Invoke interface method

Opcode:

185 (0xb9)

Instruction Format:

invokeinterface , indexbyte1 , indexbyte2 , nargs , 0

Stack:

Before:..., objectref, [arg1, [arg2 ...]]

After: ...

Description:

To execute the invokeinterface instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the constant pool by calculating (indexbyte1 8) | indexbyte2 .

The virtual machine then looks up the constant pool entry specified by the calculated index. The constant pool entry at that index must be a CONSTANT_InterfaceMethodref_info entry. If it hasn ­t already, The virtual machine resolves the entry. The resolved method ­s descriptor must exactly match the descriptor of one of the methods declared in the resolved interface. The method must not be an instance initialization method, " <init ", or a class initialization method, " <clinit ."

The nargs operand is an unsigned byte that indicates the number of words of parameters required by the method being invoked (including the hidden this reference). The operand stack must contain nargs - 1 words of parameters and the objectref word. The parameter words must match the order and type of parameters required by the resolved method. The objectref word, the reference to the object upon which to invoke the instance method, must be a reference . If the resolution is successful, The virtual machine pops nargs - 1 parameter words and objectref .

To invoke the method, The virtual machine retrieves the direct reference to the instance method to invoke from a method table. It locates the method table for the class of object pointed to by objectref and searches through it for a method with a name and descriptor that matches exactly the name and descriptor of the resolved method. (If the object ­s class is an array type, The virtual machine uses the method table for class java.lang.Object . An array type, of course, can only implement an interface if Object itself implements the interface.)

If the method is synchronized, the Java Virtual Machine, on behalf of the current thread, acquires the monitor associated with objectref .

If the method to invoke is not native, The virtual machine creates a new stack frame for the method and pushes the new stack frame onto the current thread ­s Java stack. The virtual machine then places the objectref word and nargs - 1 parameter words that it popped from the operand stack of the calling method ­s frame into the local variables of the new stack frame. It places objectref into local variable position zero, arg1 into local variable position one, and so on. ( objectref is the hidden this reference passed to all instance methods.) The virtual machine makes the new stack frame current, sets the program counter to the address of the first instruction in the new method, and continues execution there.

If the method to invoke is native, The virtual machine invokes the native method in an implementation-dependent manner.

As a result of executing this instruction, The virtual machine may throw any of the linking errors listed in Chapter 8, "The Linking Model," as possible during resolution of a CONSTANT_InterfaceMethodref_info entry. If no method exists in the object ­s class with the required name and descriptor, The virtual machine throws IncompatibleClassChangeError . Else, if the method exists but is static, The virtual machine throws IncompatibleClassChangeError . Else, if the method exists, but is not public, the virtual machine throws IllegalAccessError . Else, if the method is abstract, The virtual machine throws AbstractMethodError . Else, if the method is native and the native implementation of the method can ­t be loaded or linked, The virtual machine throws UnsatisfiedLinkError . Otherwise, if objectref is null , The virtual machine throws NullPointerException .

For more information about the invokeinterface instruction, see Chapter 19, "Method Invocation and Return."

invokespecial

- Invoke instance method with special handling for private, superclass, and instance initialization methods

Opcode:

183 (0xb7)

Instruction Format:

invokespecial , indexbyte1 , indexbyte2

Stack:

Before:..., objectref, [arg1, [arg2 ...]]

After: ...

Description:

To execute the invokespecial instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the constant pool by calculating (indexbyte1 8) | indexbyte2 .

The virtual machine then looks up the constant pool entry specified by the calculated index. The constant pool entry at that index must be a CONSTANT_Methodref_info entry. If it hasn ­t already, The virtual machine resolves the entry, which yields a direct reference to the method ­s data, including the number of words of parameters to the method, nargs . The resolved method ­s descriptor must exactly match the descriptor of one of the methods declared in the resolved class. The method must not be a class initialization method, " <clinit ."

The invokespecial instruction is used to invoke three special kinds of instance methods: superclass methods, private methods, and instance initialization methods. invokespecial contrasts with invokevirtual in the way it invokes an instance method. Whereas invokevirtual always selects the method to invoke at run-time based on the class of the object (dynamic binding), invokespecial normally (with one exception) selects the method to invoke at compile-time based on the type of the reference (static binding).

The one exception to invokespecial ­s pure static binding behavior occurs if

o the resolved method is not private and is not an instance initialization method,

o the resolved method ­s class is a superclass of the current method ­s class,

o and the ACC_SUPER flag is set in the current method ­s class.

In this situation, the Java Virtual Machine dynamically selects at run-time the method to invoke by finding the method in the closest superclass that has a descriptor that exactly matches the resolved method ­s descriptor, irrespective of the class of the resolved method. In the majority of cases, the class of the selected method will most likely be the class of the resolved method anyway, but it is possible that it could be some other class.

For example, imagine you create an inheritance hierarchy of three classes: Animal , Dog , and CockerSpaniel . Assume class Dog extends class Animal , class CockerSpaniel extends class Dog , and that a method defined in CockerSpaniel uses invokespecial to invoke a non-private superclass method named walk() . Assume also that when you compiled CockerSpaniel , the compiler set the ACC_SUPER flag. In addition, assume that when you compiled CockerSpaniel , class Animal defined a walk() method, but Dog didn ­t. In that case, the symbolic reference from CockerSpaniel to the walk() method would give Animal as its class. When the invokespecial instruction in CockerSpaniel ­s method is executed, The virtual machine would dynamically select and invoke Animal ­s walk() method.

Now imagine that later, you added a walk() method to Dog , and recompiled Dog , but didn ­t recompile CockerSpaniel . CockerSpaniel ­s symbolic reference to the superclass walk() method still claims Animal as its class, even though there is now an implementation of walk() in Dog ­s class file. Nevertheless, when the invokespecial instruction in CockerSpaniel ­s method is executed, The virtual machine would dynamically select and invoke Dog ­s implementation of the walk() method.

This special (not static binding) treatment of superclass invocations was the motivation for adding the ACC_SUPER flag to the class access_flags item of class files, and for changing the name of this opcode from its original name, invokenonvirtual , to its current name, invokespecial . If the CockerSpaniel class of the previous example had been compiled by an old compiler that didn ­t set the ACC_SUPER flag, The virtual machine would invoke Animal ­s implementation of walk() regardless of whether Dog declared a walk() . As mentioned in Chapter 6, "The Java Class File," all new Java compilers should set the ACC_SUPER flag in every class file they generate.

If the resolved method is an instance initialization method, " <init ," the method must be invoked only once on each uninitialized (except to default initial values) object. In addition, an instance initialization method must be invoked on each uninitialized object before the first backwards branch. In other words, the bytecodes of a method need not call an <init method with invokespecial right after a new instruction. Other instructions could intervene between the new and the invokespecial for the <init , but none of those instructions may branch backwards (such as a goto to the beginning of the method).

The operand stack must contain nargs - 1 words of parameters and the objectref word. The parameter words must match the order and type of parameters required by the resolved method. The objectref word, the reference to the object upon which to invoke the instance method, must be a reference . If the resolution is successful, The virtual machine pops nargs - 1 parameter words and objectref .

If the method is synchronized, the Java Virtual Machine, on behalf of the current thread, acquires the monitor associated with objectref .

If the method to invoke is not native, The virtual machine creates a new stack frame for the method and pushes the new stack frame onto the current thread ­s Java stack. The virtual machine then places the objectref word and nargs - 1 parameter words that it popped from the operand stack of the calling method ­s frame into the local variables of the new stack frame. It places objectref into local variable position zero, arg1 into local variable position one, and so on. ( objectref is the hidden this reference passed to all instance methods.) The virtual machine makes the new stack frame current, sets the program counter to the address of the first instruction in the new method, and continues execution there.

If the method to invoke is native, The virtual machine invokes the native method in an implementation-dependent manner.

As a result of executing this instruction, The virtual machine may throw any of the linking errors listed in Chapter 8, "The Linking Model," as possible during resolution of a CONSTANT_Methodref_info entry. As part of the process of resolving the CONSTANT_Methodref_info entry, The virtual machine checks whether the method ­s access permission enables the current class to access the method. If the method is protected, The virtual machine makes certain the method is a member of the either the current class or a superclass of the current class, and that the class of the object pointed to by objectref is either the current class or a subclass of the current class. If not (or if there is any other access permission problem), The virtual machine throws IllegalAccessError . Else, if the method exists and is accessible from the current class, but the method is static, The virtual machine throws IncompatibleClassChangeError . Else, if the method is abstract, The virtual machine throws AbstractMethodError . Else, if the method is native and the native implementation of the method can ­t be loaded or linked, The virtual machine throws UnsatisfiedLinkError . Otherwise, if objectref is null , The virtual machine throws NullPointerException .

For more information about the invokespecial instruction, see Chapter 19, "Method Invocation and Return."

invokestatic

- Invoke a class (static) method

Opcode:

184 (0xb8)

Instruction Format:

invokestatic , indexbyte1 , indexbyte2

Stack:

Before:..., [arg1, [arg2 ...]

After: ...

Description:

To execute the invokestatic instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the constant pool by calculating (indexbyte1 8) | indexbyte2 .

The virtual machine then looks up the constant pool entry specified by the calculated index. The constant pool entry at that index must be a CONSTANT_Methodref_info entry. If it hasn ­t already, The virtual machine resolves the entry, which yields a direct reference to the method ­s data, including the number of words of parameters to the method, nargs . The resolved method ­s descriptor must exactly match the descriptor of one of the methods declared in the resolved class. The method must not be an instance initialization method, " <init ", or a class initialization method, " <clinit ."

The operand stack must contain nargs words of parameters. The parameter words must match the order and type of parameters required by the resolved method. If the resolution is successful, The virtual machine pops the nargs parameter words.

If the method is synchronized, the Java Virtual Machine, on behalf of the current thread, acquires the monitor associated with the Class instance that represents the resolved method ­s class.

If the method to invoke is not native, The virtual machine creates a new stack frame for the method and pushes the new stack frame onto the current thread ­s Java stack. The virtual machine then places the nargs parameter words that it popped from the operand stack of the calling method ­s frame into the local variables of the new stack frame. It places arg1 into local variable position zero, arg2 into local variable position one, and so on. The virtual machine makes the new stack frame current, sets the program counter to the address of the first instruction in the new method, and continues execution there.

If the method to invoke is native, The virtual machine invokes the native method in an implementation-dependent manner.

As a result of executing this instruction, The virtual machine may throw any of the linking errors listed in Chapter 8, "The Linking Model," as possible during resolution of a CONSTANT_Methodref_info entry. As part of the process of resolving the CONSTANT_Methodref_info entry, The virtual machine checks whether the method ­s access permission enables the current class to access the method. If the method is protected, The virtual machine makes certain the method is a member of the either the current class or a superclass of the current class. If not (or if there is any other access permission problem), The virtual machine throws IllegalAccessError . Else, if the method exists and is accessible from the current class, but the method is not static, The virtual machine throws IncompatibleClassChangeError . Else, if the method is abstract, The virtual machine throws AbstractMethodError . Otherwise, if the method is native and the native implementation of the method can ­t be loaded or linked, The virtual machine throws UnsatisfiedLinkError .

For more information about the invokestatic instruction, see Chapter 19, "Method Invocation and Return."

invokevirtual

- Invoke instance method,dispatch based on an object ­s class at run-time

Opcode:

182 (0xb6)

Instruction Format:

invokevirtual , indexbyte1 , indexbyte2

Stack:

Before:..., objectref, [arg1, [arg2 ...]]

After: ...

Description:

To execute the invokevirtual instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the constant pool by calculating (indexbyte1 8) | indexbyte2 .

The virtual machine then looks up the constant pool entry specified by the calculated index. The constant pool entry at that index must be a CONSTANT_Methodref_info entry. If it hasn ­t already, The virtual machine resolves the entry, which yields the method ­s method table index, index , and the number of words of parameters to the method, nargs . The resolved method ­s descriptor must exactly match the descriptor of one of the methods declared in the resolved class. The method must not be an instance initialization method, " <init ", or a class initialization method, " <clinit ."

The operand stack must contain nargs - 1 words of parameters and the objectref word. The parameter words must match the order and type of parameters required by the resolved method. The objectref word, the reference to the object upon which to invoke the instance method, must be a reference . If the resolution is successful, The virtual machine pops nargs - 1 parameter words and objectref .

To invoke the method, The virtual machine retrieves the direct reference to the instance method to invoke from a method table. It locates the method table for the class of object pointed to by objectref and looks up the direct reference that occupies method table position index . (If the object ­s class is an array type, The virtual machine uses the method table for class java.lang.Object .)

If the method is synchronized, the Java Virtual Machine, on behalf of the current thread, acquires the monitor associated with objectref .

If the method to invoke is not native, The virtual machine creates a new stack frame for the method and pushes the new stack frame onto the current thread ­s Java stack. The virtual machine then places the objectref word and nargs - 1 parameter words that it popped from the operand stack of the calling method ­s frame into the local variables of the new stack frame. It places objectref into local variable position zero, arg1 into local variable position one, and so on. ( objectref is the hidden this reference passed to all instance methods.) The virtual machine makes the new stack frame current, sets the program counter to the address of the first instruction in the new method, and continues execution there.

If the method to invoke is native, The virtual machine invokes the native method in an implementation-dependent manner.

As a result of executing this instruction, The virtual machine may throw any of the linking errors listed in Chapter 8, "The Linking Model," as possible during resolution of a CONSTANT_Methodref_info entry. As part of the process of resolving the CONSTANT_Methodref_info entry, The virtual machine checks whether the method ­s access permission enables the current class to access the method. If the method is protected, The virtual machine makes certain the method is a member of the either the current class or a superclass of the current class, and that the class of the object pointed to by objectref is either the current class or a subclass of the current class. If not (or if there is any other access permission problem), The virtual machine throws IllegalAccessError . Else, if the method exists and is accessible from the current class, but the method is static, The virtual machine throws IncompatibleClassChangeError . Else, if the method is abstract, The virtual machine throws AbstractMethodError . Else, if the method is native and the native implementation of the method can ­t be loaded or linked, The virtual machine throws UnsatisfiedLinkError . Otherwise, if objectref is null , The virtual machine throws NullPointerException .

For more information about the invokevirtual instruction, see Chapter 19, "Method Invocation and Return."

ior

- Perform boolean OR on int s

Opcode:

128 (0x80)

Instruction Format:

ior

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the ior instruction, the Java Virtual Machine pops value1 and value2 , bitwise ORs them, and pushes the int result .

For more information about the ior instruction, see Chapter 13, "Logic."

irem

- Calculate remainder of division of int s

Opcode:

112 (0x70)

Instruction Format:

irem

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the irem instruction, the Java Virtual Machine pops value1 and value2 , calculates the integer remainder, and pushes the int result . The integer remainder equals value1 - (value1 / value2) * value2 .

The irem instruction implements Java ­s remainder operator: % . The irem behaves such that the Java expression shown below is always true , where n and d are any two int s:

begin

(n/d)*d + (n%d) == n

end

This behavior means that the result of an irem instruction always takes the same sign as the numerator, which is popped off the operand stack as value1 .

If value2 (the denominator) is zero, the Java Virtual Machine throws ArithmeticException .

For more information about the irem instruction, see Chapter 12, "Integer Arithmetic."

ireturn

- Return int from method

Opcode:

172 (0xac)

Instruction Format:

ireturn

Stack:

Before: ..., value

After: [empty]

Description:

The return type of the returning method must be byte , short , int , or char . The top word of the operand stack, value , must be an int . To execute the ireturn instruction, the Java Virtual Machine pops int value from the operand stack of the current frame and pushes it onto the operand stack of the invoking method ­s frame. The virtual machine discards any other words that may still be on the returning method ­s frame. If the returning method is synchronized, the monitor that was acquired when the method was invoked is released. The invoking method ­s frame is made current, and The virtual machine continues execution in the invoking method.

For more information about the ireturn instruction, see Chapter 19, "Method Invocation and Return." For more information about monitors, see Chapter 20, "Thread Synchronization."

ishl

- Perform left shift on int

Opcode:

120 (0x78)

Instruction Format:

ishl

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the ishl instruction, the Java Virtual Machine pops value1 and value2 , shifts value1 left by the number of bits specified in the 5 lowest order bits of value2 (from 0 to 31 bit positions ), and pushes the int result .

For more information about the ishl instruction, see Chapter 13, "Logic."

ishr

- Perform arithmetic right shift on int

Opcode:

122 (0x7a)

Instruction Format:

ishr

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the ishr instruction, the Java Virtual Machine pops value1 and value2 , shifts value1 right with sign extension by the number of bits specified in the 5 lowest order bits of value2 (from 0 to 31 bit positions), and pushes the int result .

For more information about the ishr instruction, see Chapter 13, "Logic."

istore

- Store int into local variable

Opcode:

54 (0x36)

Instruction Format:

istore , index

Stack:

Before:..., value

After: ...

Description:

The index operand must specify a valid 8-bit unsigned index into the local variables of the current frame. The value word on the top of the operand stack must be an int . To execute the istore instruction, the Java Virtual Machine pops the int value from the top of the operand stack and stores it into the local variable word specified by index .

Note that the wide instruction can precede the istore instruction, to enable a value to be stored into a local variable specified by a 16-bit unsigned offset.

For more information about the istore instruction, see Chapter 10, "Stack Operations."

istore_0

- Store int into local variable 0

Opcode:

59 (0x3b)

Instruction Format:

istore_0

Stack:

Before: ..., value

After: ...

Description:

The index zero must be a valid index into the local variables of the current stack frame, and the value word on the top of the operand stack must be an int . To execute the istore_0 instruction, the Java Virtual Machine pops the int value from the top of the operand stack and stores it into the local variable word at index zero.

For more information about the istore_0 instruction, see Chapter 10, "Stack Operations."

istore_1

- Store int into local variable 1

Opcode:

60 (0x3c)

Instruction Format:

istore_1

Stack:

Before: ..., value

After: ...

Description:

The index one must be a valid index into the local variables of the current stack frame, and the value word on the top of the operand stack must be an int . To execute the istore_1 instruction, the Java Virtual Machine pops the int value from the top of the operand stack and stores it into the local variable word at index one.

For more information about the istore_1 instruction, see Chapter 10, "Stack Operations."

istore_2

- Store int into local variable 2

Opcode:

61 (0x3d)

Instruction Format:

istore_2

Stack:

Before: ..., value

After: ...

Description:

The index two must be a valid index into the local variables of the current stack frame, and the value word on the top of the operand stack must be an int . To execute the istore_2 instruction, the Java Virtual Machine pops the int value from the top of the operand stack and stores it into the local variable word at index two.

For more information about the istore_2 instruction, see Chapter 10, "Stack Operations."

istore_3

- Store int into local variable 3

Opcode:

62 (0x3e)

Instruction Format:

istore_3

Stack:

Before: ..., value

After: ...

Description:

The index three must be a valid index into the local variables of the current stack frame, and the value word on the top of the operand stack must be an int . To execute the istore_3 instruction, the Java Virtual Machine pops the int value from the top of the operand stack and stores it into the local variable word at index three.

For more information about the istore_3 instruction, see Chapter 10, "Stack Operations."

isub

- Subtract int s

Opcode:

100 (0x64)

Instruction Format:

isub

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the isub instruction, the Java Virtual Machine pops value1 and value2 , subtracts value2 from value1 ( value1 - value2 ), and pushes the int result . If overflow occurs, result is the 32 lowest order bits of the true mathematical result represented in a sufficiently wide two ­s-complement format, and the sign bit of result may be different from the true mathematical result.

For more information about the isub instruction, see Chapter 12, "Integer Arithmetic."

iushr

- Perform logical right shift on int

Opcode:

124 (0x7c)

Instruction Format:

iushr

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the iushr instruction, the Java Virtual Machine pops value1 and value2 , shifts value1 right with zero extension by the number of bits specified in the 5 lowest order bits of value2 (from 0 to 31 bit positions), and pushes the int result .

For more information about the iushr instruction, see Chapter 13, "Logic."

ixor

- Perform boolean XOR on int s

Opcode:

130 (0x82)

Instruction Format:

ixor

Stack:

Before: ..., value1, value2

After: ..., result

Description:

The top two words of the operand stack, value1 and value2 , must be int s. To execute the ixor instruction, the Java Virtual Machine pops value1 and value2 , bitwise exclusive ORs them, and pushes the int result .

For more information about the ixor instruction, see Chapter 13, "Logic."

jsr

- Jump to subroutine

Opcode:

168 (0xa8)

Instruction Format:

jsr , branchbyte1 , branchbyte2

Stack:

Before:...

After: ..., address

Description:

To execute the jsr instruction, the Java Virtual Machine pushes the (program counter) address of the opcode immediately following the jsr instruction, the address word, onto the operand stack.

The virtual machine then forms a signed 16-bit offset by calculating (branchbyte1 8) | branchbyte2 . It calculates a target (program counter) address by adding the calculated offset to the address of the jsr opcode. The target address must be the address of an opcode within the same method as the jsr opcode. The virtual machine jumps to the target address and continues execution there.

For more information about the jsr instruction, see Chapter 18, "Finally Clauses."

jsr_w

- Jump to subroutine (wide index)

Opcode:

201 (0xc9)

Instruction Format:

jsr_w , branchbyte1 , branchbyte2 , branchbyte3 , branchbyte4

Stack:

Before:...

After: ..., address

Description:

To execute the jsr_w instruction, the Java Virtual Machine pushes the (program counter) address of the opcode immediately following the jsr_w instruction, the address word, onto the operand stack.

The virtual machine then forms a signed 32-bit offset by calculating (branchbyte1 24) | (branchbyte2 16) | (branchbyte3 8) | branchbyte4 . The virtual machine then calculates a target (program counter) address by adding the calculated offset to the address of the jsr_w opcode. The target address must be the address of an opcode within the same method as the jsr_w opcode. The virtual machine jumps to the target address and continues execution there.

Note that despite the 32-bit offset of the jsr_w instruction, Java methods are currently (in both the 1.0 and 1.1 releases) limited to 65,535 bytes by three items in the Java class file format: the sizes of the indexes in the LineNumberTable attribute, the LocalVariableTable attribute, and the Code attribute ­s exception_table item. According to the Java Virtual Machine specification, the 65,536 byte limit to Java methods may be raised in a future release. For more information about the jsr_w instruction, see Chapter 18, "Finally Clauses."

l2d

- Convert long to double

Opcode:

138 (0x8a)

Instruction Format:

l2d

Stack:

Before: ..., value.word1, value.word2

After: ..., result.word1, result.word2

Description:

The top two words of the operand stack must be a long . To execute the l2d instruction, the Java Virtual Machine pops the long value from the operand stack, converts the long to a double using the IEEE round-to-nearest mode, and pushes the double result .

Note that this instruction performs a widening primitive conversion. Because not all long values are exactly representable by a double , the conversion may result in a loss of precision.

For more information about the l2d instruction, see Chapter 11, "Type Conversion."

l2f

- Convert long to float

Opcode:

137 (0x89)

Instruction Format:

l2f

Stack:

Before: ..., value.word1, value.word2

After: ..., result

Description:

The top two words of the operand stack must be a long . To execute the l2f instruction, the Java Virtual Machine pops the long value from the operand stack, converts the long to a float using the IEEE round-to-nearest mode, and pushes the float result .

Note that this instruction performs a widening primitive conversion. Because not all long values are exactly representable by a float , the conversion may result in a loss of precision.

For more information about the l2f instruction, see Chapter 11, "Type Conversion."

l2i

- Convert long to int

Opcode:

136 (0x88)

Instruction Format:

l2i

Stack:

Before: ..., value.word1, value.word2

After: ..., result

Description:

The top two words of the operand stack must be a long . To execute the l2i instruction, the Java Virtual Machine pops long value from the operand stack, truncates the long to a int , and pushes the int result .

Note that this instruction performs a narrowing primitive conversion. As a result of this conversion, magnitude information may be lost and the sign bit may change.

For more information about the l2i instruction, see Chapter 11, "Type Conversion."

ladd

- Add long s

Opcode:

97 (0x61)

Instruction Format:

ladd

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result.word1, result.word2

Description:

The top four words of the operand stack must be two long s, value1 and value2 . To execute the ladd instruction, the Java Virtual Machine pops value1 and value2 , adds them, and pushes the long result . If overflow occurs, result is the 64 lowest order bits of the true mathematical result represented in a sufficiently wide two ­s-complement format, and the sign of result is different from that of the true mathematical result.

For more information about the ladd instruction, see Chapter 12, "Integer Arithmetic."

laload

- Load long from array

Opcode:

47 (0x2f)

Instruction Format:

laload

Stack:

Before: ..., arrayref, index

After: ..., value.word1, value.word2

Description:

To execute the laload instruction, the Java Virtual Machine first pops two words from the operand stack. The arrayref word must be a reference that refers to an array of long s. The index word must be an int . The virtual machine retrieves from the arrayref array the long value specified by index and pushes it onto the operand stack.

If arrayref is null , the Java Virtual Machine throws NullPointerException . Otherwise, if index is not a legal index into the arrayref array, The virtual machine throws ArrayIndexOutOfBoundsException .

For more information about the laload instruction, see Chapter 15, "Objects and Arrays."

land

- Perform boolean AND on long s

Opcode:

127 (0x7f)

Instruction Format:

land

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result.word1, result.word2

Description:

The top four words of the operand stack must be two long s, value1 and value2 . To execute the land instruction, the Java Virtual Machine pops value1 and value2 , bitwise ANDs them, and pushes the long result .

For more information about the land instruction, see Chapter 13, "Logic."

lastore

- Store into long array

Opcode:

80 (0x50)

Instruction Format:

lastore

Stack:

Before: ..., arrayref, index, value.word1, value.word2

After: ...

Description:

To execute the laload instruction, the Java Virtual Machine first pops four words from the operand stack. The arrayref word must be a reference that refers to an array of long s. The index word must be an int , and the value words must be a long . The virtual machine stores long value into the arrayref array location specified by index .

If arrayref is null , the Java Virtual Machine throws NullPointerException . Otherwise, if index is not a legal index into the arrayref array, The virtual machine throws ArrayIndexOutOfBoundsException .

For more information about the lastore instruction, see Chapter 15, "Objects and Arrays."

lcmp

- Compare long s

Opcode:

148 (0x94)

Instruction Format:

lcmp

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result

Description:

The top four words of the operand stack must be two long s, value1 and value2 . To execute the lcmp instruction, the Java Virtual Machine pops value1 and value2 off the operand stack and compares one against the other. If value1 equals value2 , The virtual machine pushes onto the operand stack int result zero. Else, if value1 is greater than value2 , The virtual machine pushes onto the operand stack int result one. Otherwise, if value1 is less than value2 , The virtual machine pushes onto the operand stack int result negative one.

For more information about the lcmp instruction, see Chapter 16, "Control Flow."

lconst_0

- Push long constant 0

Opcode:

9 (0x9)

Instruction Format:

lconst_0

Stack:

Before: ...

After: ..., <0-word1, <0-word2

Description:

To execute the lconst_0 instruction, the Java Virtual Machine pushes the long constant 0 onto the operand stack.

For more information about the lconst_0 instruction, see Chapter 10, "Stack Operations."

lconst_1

- Push long constant 1

Opcode:

10 (0xa)

Instruction Format:

lconst_1

Stack:

Before: ...

After: ..., <1-word1, <1-word2

Description:

To execute the lconst_1 instruction, the Java Virtual Machine pushes the long constant 1 onto the operand stack.

For more information about the lconst_1 instruction, see Chapter 10, "Stack Operations."

ldc

- Push item from constant pool

Opcode:

18 (0x12)

Instruction Format:

ldc , index

Stack:

Before:...

After: ..., item

Description:

The index operand must be a valid unsigned 8-bit index into the current constant pool. To execute the ldc instruction, the Java Virtual Machine first looks up the constant pool entry specified by the index operand. At constant pool entry index ,

The virtual machine must find either a CONSTANT_Integer_info , CONSTANT_Float_info , or CONSTANT_String_info entry. If it hasn ­t already, The virtual machine resolves the entry. If the entry is a CONSTANT_Integer_info , The virtual machine pushes the int value represented by the entry onto the operand stack. Else, if the entry is a CONSTANT_Float_info , The virtual machine pushes the float value represented by the entry onto the operand stack. Otherwise, the entry is a CONSTANT_String_info entry, and The virtual machine pushes a reference to the interned String object that was produced by the process of resolving the entry onto the operand stack.

Note that the ldc_w instruction performs the same function, but offers a wide (16-bit) constant pool index.

For more information about the ldc instruction, see Chapter 10, "Stack Operations."

ldc_w

- Push item from constant pool (wide index)

Opcode:

19 (0x13)

Instruction Format:

ldc_w , indexbyte1 , indexbyte2

Stack:

Before:...

After: ..., item

Description:

To execute the ldc_w instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the constant pool by calculating (indexbyte1 8) | indexbyte2 .

The virtual machine then looks up the constant pool entry specified by the calculated index. The constant pool entry at that index must be either a CONSTANT_Integer_info , a CONSTANT_Float_info , or a CONSTANT_String_info entry. If it hasn ­t already, The virtual machine resolves the entry. If the entry is a CONSTANT_Integer_info , The virtual machine pushes the int value represented by the entry onto the operand stack. Else, if the entry is a CONSTANT_Float_info , The virtual machine pushes the float value it represents onto the operand stack. Otherwise, the entry is a CONSTANT_String_info , and The virtual machine pushes a reference to the interned String object that was produced by the process of resolving the entry onto the operand stack.

Note that the ldc_w instruction performs the same function as ldc , but offers a wide (16-bit) constant pool index as opposed to ldc ­s 8-bit constant pool index.

For more information about the ldc_w instruction, see Chapter 10, "Stack Operations."

ldc2_w

- Push long or double from constant pool (wide index)

Opcode:

20 (0x14)

Instruction Format:

ldc2_w , indexbyte1 , indexbyte2

Stack:

Before:...

After: ..., item.word1, item.word2

Description:

To execute the ldc2_w instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the constant pool by calculating (indexbyte1 8) | indexbyte2 .

The virtual machine then looks up the constant pool entry specified by the calculated index. The constant pool entry at that index must be either a CONSTANT_Long_info or CONSTANT_Double_info entry. The virtual machine resolves the entry. If the entry is a CONSTANT_Long_info , The virtual machine pushes the long value represented by the entry onto the operand stack. Otherwise, it is a CONSTANT_Double_info entry, and The virtual machine pushes the double value represented by the entry onto the operand stack.

Note that there is no " ldc2 " instruction that performs the same function as ldc2_w but with an 8-bit constant pool index. All two-word constants must be retrieved from the constant pool with an ldc2_w instruction, which has a wide (16-bit) constant pool index.

For more information about the ldc2_w instruction, see Chapter 10, "Stack Operations."

ldiv

- Divide long s

Opcode:

109 (0x6d)

Instruction Format:

ldiv

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result.word1, result.word2

Description:

The top four words of the operand stack must be two long s, value1 and value2 . To execute the ldiv instruction, the Java Virtual Machine pops value1 and value2 , integer divides value1 by value2 ( value1 / value2 ), and pushes the long result .

Integer division rounds the magnitude of the true mathematical quotient towards zero to the nearest integer. If the magnitude of the denominator is greater than that of the numerator, the long result is zero. Else, with one special exception, the sign of result is positive if the signs of the numerator and denominator are the same, negative if they are different. The exception to this rule is when the numerator is the smallest negative integer that can be represented by a long and the denominator is -1. For this division, the true mathematical result is one greater than the largest positive integer that can be represented by a long . As a consequence, the division overflows and the result is equal to the numerator.

If value2 (the denominator) is zero, the Java Virtual Machine throws ArithmeticException .

For more information about the ldiv instruction, see Chapter 12, "Integer Arithmetic."

lload

- Load long from local variable

Opcode:

22 (0x16)

Instruction Format:

lload , index

Stack:

Before:...

After: ..., value.word1, value.word2

Description:

The index operand, which serves as an 8-bit unsigned index into the local variables of the current frame, must specify the first of two consecutive local variable words that contain a long . To execute the lload instruction, the Java Virtual Machine pushes onto the operand stack the long contained in the two consecutive local variable words specified by index and index + 1 .

Note that the wide instruction can precede the lload instruction, to allow a local variable to be accessed with a 16-bit unsigned offset.

For more information about the lload instruction, see Chapter 10, "Stack Operations."

lload_0

- Load long from local variable 0

Opcode:

30 (0x1e)

Instruction Format:

lload_0

Stack:

Before: ...

After: ..., value.word1, value.word2

Description:

The two consecutive local variable words at indexes zero and one must contain a long . To execute the lload_0 instruction, the Java Virtual Machine pushes onto the operand stack the long value contained in local variable words zero and one.

For more information about the lload_0 instruction, see Chapter 10, "Stack Operations."

lload_1

- Load long from local variable 1

Opcode:

31 (0x1f)

Instruction Format:

lload_1

Stack:

Before: ...

After: ..., value.word1, value.word2

Description:

The two consecutive local variable words at indexes one and two must contain a long . To execute the lload_1 instruction, the Java Virtual Machine pushes onto the operand stack the long value contained in local variable words one and two.

For more information about the lload_1 instruction, see Chapter 10, "Stack Operations."

lload_2

- Load long from local variable 2

Opcode:

32 (0x20)

Instruction Format:

lload_2

Stack:

Before: ...

After: ..., value.word1, value.word2

Description:

The two consecutive local variable words at indexes two and three must contain a long . To execute the lload_2 instruction, the Java Virtual Machine pushes onto the operand stack the long value contained in local variable words two and three.

For more information about the lload_2 instruction, see Chapter 10, "Stack Operations."

lload_3

- Load long from local variable 3

Opcode:

33 (0x21)

Instruction Format:

lload_3

Stack:

Before: ...

After: ..., value.word1, value.word2

Description:

The two consecutive local variable words at indexes three and four must contain a long . To execute the lload_3 instruction, the Java Virtual Machine pushes onto the operand stack the long value contained in local variable words three and four.

For more information about the lload_3 instruction, see Chapter 10, "Stack Operations."

lmul

- Multiply long s

Opcode:

105 (0x69)

Instruction Format:

lmul

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result.word1, result.word2

Description:

The top four words of the operand stack must be two long s, value1 and value2 . To execute the lmul instruction, the Java Virtual Machine pops value1 and value2 , multiplies them, and pushes the long result . If overflow occurs, result is the 64 lowest order bits of the true mathematical result represented in a sufficiently wide two ­s-complement format, and the sign of result may be different from that of the true mathematical result.

For more information about the lmul instruction, see Chapter 12, "Integer Arithmetic."

lneg

- Negate long

Opcode:

117 (0x75)

Instruction Format:

lneg

Stack:

Before: ..., value.word1, value.word2

After: ..., result.word1, result.word2

Description:

The top two words of the operand stack must be a long , value . To execute the lneg instruction, the Java Virtual Machine pops value , negates it, and pushes the long result .

The result produced by an lneg instruction is the same number that would be produced by subtracting value from zero with the lsub instruction. As a consequence, when value is the smallest negative integer that can be represented by an long , the negation overflows. For this negation, the true mathematical result is one greater than the largest positive integer that can be represented by an long , and the actual result is equal to value with no change in sign.

For more information about the lneg instruction, see Chapter 12, "Integer Arithmetic."

lookupswitch

- Access jump table by key match and jump

Opcode:

171 (0xab)

Instruction Format:

lookupswitch , ...0-3 byte pad... , defaultbyte1 , defaultbyte2 , defaultbyte3 , defaultbyte4 , npairs1 , npairs2 , npairs3 , npairs4 , ..match-offset pairs..

Stack:

Before:..., key

After: ...

Description:

The lookupswitch opcode is followed by zero to three bytes of padding--enough so that the byte immediately following the padding starts at an address that is a multiple of four bytes from the beginning of the method. Each padding byte is a zero. Immediately following the padding is a signed 32-bit default branch offset, default . Following default is npairs , a signed count of the number of case value/branch offset pairs embedded in this lookupswitch instruction. The value of npairs must be greater than or equal to zero. Following npairs are the case value/branch offset pairs themselves . For each pair, the signed 32-bit case value, match , precedes the signed 32-bit branch offset, offset .

The virtual machine calculates all of these signed 32-bit values from the four individual bytes as (byte1 24) | (byte2 16) | (byte3 8) | byte4 .

The top word of the operand stack, key , must be an int . To execute the lookupswitch instruction, the Java Virtual Machine pops key off the operand stack and compares it to the match values. If the key is equal to one of the match values, The virtual machine calculates a target (program counter) address by adding the signed offset that corresponds to the matching match value to the address of the lookupswitch opcode. The target address must be the address of an opcode within the same method as the lookupswitch opcode. The virtual machine jumps to the target address and continues execution there.

For more information about the lookupswitch instruction, see Chapter 16, "Control Flow."

lor

- Perform boolean OR on long s

Opcode:

129 (0x81)

Instruction Format:

lor

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result.word1, result.word2

Description:

The top four words of the operand stack must be two long s, value1 and value2 . To execute the lor instruction, the Java Virtual Machine pops value1 and value2 , bitwise ORs them, and pushes the long result .

For more information about the lor instruction, see Chapter 13, "Logic."

lrem

- Calculate remainder of division of long s

Opcode:

113 (0x71)

Instruction Format:

lrem

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result.word1, result.word2

Description:

The top four words of the operand stack must be two long s, value1 and value2 . To execute the lrem instruction, the Java Virtual Machine pops value1 and value2 , calculates the integer remainder, and pushes the long result . The integer remainder equals value1 - (value1 / value2) * value2 .

The lrem instruction implements Java ­s remainder operator, % , on long s. The lrem behaves such that the Java expression shown below is always true , where n and d are any two long s:

begin

(n/d)*d + (n%d) == n

end

This behavior means that the result of an lrem instruction always takes the same sign as the numerator, which is popped off the operand stack as value1 .

If value2 (the denominator) is zero, the Java Virtual Machine throws ArithmeticException .

For more information about the lrem instruction, see Chapter 12, "Integer Arithmetic."

lreturn

- Return long from method

Opcode:

173 (0xad)

Instruction Format:

lreturn

Stack:

Before: ..., value.word1, value.word2

After: [empty]

Description:

The return type of the returning method must be long . The top two words of the operand stack must be a long . To execute the lreturn instruction, the Java Virtual Machine pops the long value from the operand stack of the current frame and pushes it onto the operand stack of the invoking method ­s frame. The virtual machine discards any other words that may still be on the returning method ­s frame. If the returning method is synchronized, the monitor that was acquired when the method was invoked is released. The invoking method ­s frame is made current, and The virtual machine continues execution in the invoking method.

For more information about monitors, see Chapter 20, "Thread Synchronization." For more information about the lreturn instruction, see Chapter 19, "Method Invocation and Return."

lshl

- Perform left shift on long

Opcode:

121 (0x79)

Instruction Format:

lshl

Stack:

Before: ..., value1.word1, value1.word2, value2

After: ..., result.word1, result.word2

Description:

The top word of the operand stack, value2 , must be an int . The next two words down must be a long , value1 . To execute the lshl instruction, the Java Virtual Machine pops value1 and value2 , shifts value1 left by the number of bits specified in the 6 lowest order bits of value2 (from 0 to 63 bit positions), and pushes the long result .

For more information about the lshl instruction, see Chapter 13, "Logic."

lshr

- Perform arithmetic right shift on long

Opcode:

123 (0x7b)

Instruction Format:

lshr

Stack:

Before: ..., value1.word1, value1.word2, value2

After: ..., result.word1, result.word2

Description:

The top word of the operand stack, value2 , must be an int . The next two words down must be a long , value1 . To execute the lshr instruction, the Java Virtual Machine pops value1 and value2 , shifts value1 right with sign extension by the number of bits specified in the 6 lowest order bits of value2 (from 0 to 63 bit positions), and pushes the long result .

For more information about the lshr instruction, see Chapter 13, "Logic."

lstore

- Store long into local variable

Opcode:

55 (0x37)

Instruction Format:

lstore , index

Stack:

Before:..., value.word1, value.word2

After: ...

Description:

The index operand must specify a valid 8-bit unsigned index into the local variables of the current frame. The top two words of the operand stack must be a long . To execute the lstore instruction, the Java Virtual Machine pops the long value from the top of the operand stack and stores it into the two consecutive local variable words at indexes index and index + 1 .

Note that the wide instruction can precede the lstore instruction, to enable a value to be stored into a local variable specified by a 16-bit unsigned offset.

For more information about the lstore instruction, see Chapter 10, "Stack Operations."

lstore_0

- Store long into local variable 0

Opcode:

63 (0x3f)

Instruction Format:

lstore_0

Stack:

Before: ..., value.word1, value.word2

After: ...

Description:

The indexes zero and one must be valid indexes into the local variables of the current stack frame. The top two words on the operand stack must be a long . To execute the lstore_0 instruction, the Java Virtual Machine pops the long value from the top of the operand stack and stores it into the two consecutive local variable words at indexes zero and one.

For more information about the lstore_0 instruction, see Chapter 10, "Stack Operations."

lstore_1

- Store long into local variable 1

Opcode:

64 (0x40)

Instruction Format:

lstore_1

Stack:

Before: ..., value.word1, value.word2

After: ...

Description:

The indexes one and two must be valid indexes into the local variables of the current stack frame. The top two words on the operand stack must be a long . To execute the lstore_1 instruction, the Java Virtual Machine pops the long value from the top of the operand stack and stores it into the two consecutive local variable words at indexes one and two.

For more information about the lstore_1 instruction, see Chapter 10, "Stack Operations."

lstore_2

- Store long into local variable 2

Opcode:

65 (0x41)

Instruction Format:

lstore_2

Stack:

Before: ..., value.word1, value.word2

After: ...

Description:

The indexes two and three must be valid indexes into the local variables of the current stack frame. The top two words on the operand stack must be a long . To execute the lstore_2 instruction, the Java Virtual Machine pops the long value from the top of the operand stack and stores it into the two consecutive local variable words at indexes two and three.

For more information about the lstore_2 instruction, see Chapter 10, "Stack Operations."

lstore_3

- Store long into local variable 3

Opcode:

66 (0x42)

Instruction Format:

lstore_3

Stack:

Before: ..., value.word1, value.word2

After: ...

Description:

The indexes three and four must be valid indexes into the local variables of the current stack frame. The top two words on the operand stack must be a long . To execute the lstore_3 instruction, the Java Virtual Machine pops the long value from the top of the operand stack and stores it into the two consecutive local variable words at indexes three and four.

For more information about the lstore_3 instruction, see Chapter 10, "Stack Operations."

lsub

- Subtract long s

Opcode:

101 (0x65)

Instruction Format:

lsub

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result.word1, result.word2

Description:

The top four words of the operand stack must be two long s, value1 and value2 . To execute the lsub instruction, the Java Virtual Machine pops value1 and value2 , subtracts value2 from value1 ( value1 - value2 ), and pushes the long result . If overflow occurs, result is the 64 lowest order bits of the true mathematical result represented in a sufficiently wide two ­s-complement format, and the sign bit of result is different from the true mathematical result.

For more information about the lsub instruction, see Chapter 12, "Integer Arithmetic."

lushr

- Perform logical right shift on long

Opcode:

125 (0x7d)

Instruction Format:

lushr

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result.word1, result.word2

Description:

The top word of the operand stack, value2 , must be an int . The next two words down must be a long , value1 . To execute the lushr instruction, the Java Virtual Machine pops value1 and value2 , shifts value1 right with zero extension by the number of bits specified in the 6 lowest order bits of value2 (from 0 to 63 bit positions), and pushes the long result .

For more information about the lushr instruction, see Chapter 13, "Logic."

lxor

- Perform boolean XOR on long s

Opcode:

131 (0x83)

Instruction Format:

lxor

Stack:

Before: ..., value1.word1, value1.word2, value2.word1, value2.word2

After: ..., result.word1, result.word2

Description:

The top four words of the operand stack must be two long s, value1 and value2 . To execute the lxor instruction, the Java Virtual Machine pops value1 and value2 , bitwise exclusive ORs them, and pushes the long result .

For more information about the lxor instruction, see Chapter 13, "Logic."

monitorenter

- Enter and acquire object monitor

Opcode:

194 (0xc2)

Instruction Format:

monitorenter

Stack:

Before: ..., objectref

After: ...

Description:

The top word of the operand stack, objectref , must be a reference .To execute the monitorenter instruction, the Java Virtual Machine pops objectref and, on behalf of the current thread, acquires the monitor associated with objectref .

If the objectref word is null ,

The virtual machine throws NullPointerException .

For more information about the monitorenter instruction, see Chapter 20, "Thread Synchronization."

monitorexit

- Release and exit object monitor

Opcode:

195 (0xc3)

Instruction Format:

monitorexit

Stack:

Before: ..., objectref

After: ...

Description:

The top word of the operand stack, objectref , must be a reference .To execute the monitorenter instruction, the Java Virtual Machine pops objectref and, on behalf of the current thread, releases and exits the monitor associated with objectref .

If the objectref word is null , The virtual machine throws NullPointerException .

For more information about the monitorexit instruction, see Chapter 20, "Thread Synchronization."

multianewarray

- Allocate new multi-dimensional array

Opcode:

197 (0xc5)

Instruction Format:

multianewarray , indexbyte1 , indexbyte2 , dimensions

Stack:

Before:..., count1, [count2,...]

After: arrayref

Description:

The dimensions operand, an unsigned byte that indicates the number of dimensions in the array to create, must be greater than or equal to one. The top dimensions words of the operand stack, count1, [count2,...] , must contain int s that have nonnegative values. Each of these words gives the number of elements in one dimension of the array. For example, consider an array declared as:

begin cc .

int[][][] example = new int[3][4][5];

end

For this array, dimensions would be equal to three and the operand stack would contain three "count" words. The count1 word would be three, count2 four, and count3 five.

To execute the multianewarray instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the constant pool by calculating (indexbyte1 8) | indexbyte2 .

The virtual machine then looks up the constant pool entry specified by the calculated index. The constant pool entry at that index must be a CONSTANT_Class_info entry. If it hasn ­t already, The virtual machine resolves the entry. The entry must be an array type of dimensionality greater than or equal to dimensions .

If the resolution is successful, the Java Virtual Machine creates the dimensions -dimensional array on the heap. The virtual machine initializes the elements of the first-dimension array with references to the second-dimension arrays; it initializes the elements of each of the second-dimension array with references to the third-dimension arrays, and so on. The virtual machine initializes the elements of the last-dimension arrays with their default initial values. Lastly, the Java Virtual Machine pushes a reference to the new dimensions -dimensional array onto the operand stack.

As a result of executing this instruction, The virtual machine may throw any of the linking errors listed in Chapter 8, "The Linking Model," as possible during resolution of a CONSTANT_Class_info entry. If resolution succeeds and the array ­s component type is a reference type, but the current class does not have permission to access that reference type, The virtual machine throws IllegalAccessError . Otherwise, if any of the counts popped off of the operand stack have a negative value, the Java Virtual Machine throws NegativeArraySizeException .

Note that the dimensionality of the array type specified in the resolved CONSTANT_Class_info entry need not be equal to the dimensions operand--it can also be greater than dimensions . For example, the name of the array class for a three-dimensional array of int s is " [[[I ." The actual constant pool entry referenced by a multianewarray instruction that creates a three-dimensional array of int s must have at least three dimensions, but may have more. For instance, resolved array types of " [[[I ," " [[[[I ," and " [[[[[[[[I " would all yield three-dimensional arrays of int so long as the dimensions operand is three. This flexibility in specifying multidimensional array types to the multianewarray instruction can reduce the number of entries required in the constant pool of some classes.

For more information about the multianewarray instruction, see Chapter 15, "Objects and Arrays."

new

- Create a new object

Opcode:

187 (0xbb)

Instruction Format:

new , indexbyte1 , indexbyte2

Stack:

Before:...

After: ..., objectref

Description:

To execute the new instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the constant pool by calculating (indexbyte1 8) | indexbyte2 .

The virtual machine then looks up the constant pool entry specified by the calculated index. The constant pool entry at that index must be a CONSTANT_Class_info entry. If it hasn ­t already, The virtual machine resolves the entry. The entry must be a class type, not an interface or array type. The virtual machine allocates sufficient memory from the heap for the new object ­s image, and sets the object ­s instance variables to their default initial values. Lastly, The virtual machine pushes objectref , a reference to the new object, onto the operand stack.

As a result of executing this instruction, The virtual machine may throw any of the linking errors listed in Chapter 8, "The Linking Model," as possible during resolution of a CONSTANT_Class_info entry. If resolution succeeds, but the resolved type is an interface, abstract class, or array, The virtual machine throws an InstantiationError . Else, if the current class doesn ­t have permission to access the resolved class, The virtual machine throws an IllegalAccessError .

For more information about the new instruction, see Chapter 15, "Objects and Arrays."

newarray

- Allocate new array of primitive type components

Opcode:

188 (0xbc)

Instruction Format:

newarray , atype

Stack:

Before:..., count

After: arrayref

Description:

The top word of the operand stack, count , must be an int . The atype operand, which is used to indicate the array type, must take one of the values shown in Table A-2. To execute the newarray instruction, the Java Virtual Machine pops count and creates on the heap an array of size count of the primitive type specified by atype .

The virtual machine initializes each array element to its default initial value and pushes arrayref , a reference to the new array, onto the operand stack.

Table A-2. Values for atype

2 columns

Array Type atype

T_BOOLEAN 4

T_CHAR 5

T_FLOAT 6

T_DOUBLE 7

T_BYTE 8

T_SHORT 9

T_INT 10

T_LONG 11

end table

If count is less than zero, the Java Virtual Machine throws NegativeArraySizeException .

For more information about the newarray instruction, see Chapter 15, "Objects and Arrays."

nop

- Do nothing

Opcode:

0 (0x0)

Instruction Format:

nop

Stack:

No change

Description:

To execute the nop instruction, the Java Virtual Machine takes a coffee break.

For more information about the nop instruction, see Chapter 10, "Stack Operations."

pop

- Pop top stack word

Opcode:

87 (0x57)

Instruction Format:

pop

Stack:

Before: ..., word

After: ...

Description:

To execute the pop instruction, the Java Virtual Machine pops the top word from the operand stack. This instruction can be used to pop any single-word value from the top of the operand stack. It must not be used to remove half of a dual word value ( long or double ) from the top of the operand stack.

For more information about the pop instruction, see Chapter 10, "Stack Operations."

pop2

- Pop top two stack words

Opcode:

88 (0x58)

Instruction Format:

pop2

Stack:

Before: ..., word2, word1

After: ...

Description:

To execute the pop2 instruction, the Java Virtual Machine pops the top two words from the operand stack. This instruction can be used to pop any dual-word value from the top of the operand stack, or any two single-word values. It must not be used to remove one single-word value and half of a dual word value ( long or double ) from the top of the operand stack.

For more information about the pop2 instruction, see Chapter 10, "Stack Operations."

putfield

- Set field in object

Opcode:

181 (0xb5)

Instruction Format:

putfield , indexbyte1 , indexbyte2

Stack:

Before:..., objectref, value

After: ...

or

Before: ..., objectref, value.word1, value.word2

After: ...

Description:

To execute the putfield instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the constant pool by calculating (indexbyte1 8) | indexbyte2 .

The virtual machine then looks up the constant pool entry specified by the calculated index. The constant pool entry at that index must be a CONSTANT_Fieldref_info entry. If it hasn ­t already, The virtual machine resolves the entry, which yields the field ­s width and the field ­s offset from the beginning of the object image.

The type of the single or double-word value occupying the top of the stack must be compatible with the descriptor of the resolved field. If the resolved field ­s descriptor is byte , short , char , boolean , or int , the type of value must be int . If the resolved field ­s descriptor is long , the type of value must be long . If the resolved field ­s descriptor is float , the type of value must be float . If the resolved field ­s descriptor is double , the type of value must be double . If the resolved field ­s descriptor is a reference type, the type of value must be reference and must be assignment-compatible the resolved descriptor type. The objectref word must be a reference .

The virtual machine pops value and objectref and assigns value to the appropriate field in the object pointed to by objectref .

As a result of executing this instruction, The virtual machine may throw any of the linking errors listed in Chapter 8, "The Linking Model," as possible during resolution of a CONSTANT_Fieldref_info entry. As part of the process of resolving the CONSTANT_Fieldref_info entry, The virtual machine checks whether the field ­s access permission enables the current class to access the field. If the field is protected, The virtual machine makes certain the field is a member of the either the current class or a superclass of the current class, and that the class of the object pointed to by objectref is either the current class or a subclass of the current class. If not (or if there is any other access permission problem), The virtual machine throws IllegalAccessError . Else, if the field exists and is accessible from the current class, but the field is static, The virtual machine throws IncompatibleClassChangeError . Otherwise, if objectref is null , The virtual machine throws NullPointerException .

For more information about the putfield instruction, see Chapter 15, "Objects and Arrays."

putstatic

- Set static field in class

Opcode:

179 (0xb3)

Instruction Format:

putstatic , indexbyte1 , indexbyte2

Stack:

Before:..., value

After: ...

or

Before: ..., value.word1, value.word2

After: ...

Description:

To execute the putstatic instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the constant pool by calculating (indexbyte1 8) | indexbyte2 .

The virtual machine then looks up the constant pool entry specified by the calculated index. The constant pool entry at that index must be a CONSTANT_Fieldref_info entry. If it hasn ­t already, The virtual machine resolves the entry.

The type of the single or double-word value occupying the top of the stack must be compatible with the descriptor of the resolved field. If the resolved field ­s descriptor is byte , short , char , boolean , or int , the type of value must be int . If the resolved field ­s descriptor is long , the type of value must be long . If the resolved field ­s descriptor is float , the type of value must be float . If the resolved field ­s descriptor is double , the type of value must be double . If the resolved field ­s descriptor is a reference type, the type of value must be reference and must be assignment-compatible the resolved descriptor type.

The virtual machine pops and assigns value to the appropriate static field.

As a result of executing this instruction, The virtual machine may throw any of the linking errors listed in Chapter 8, "The Linking Model," as possible during resolution of a CONSTANT_Fieldref_info entry. As part of the process of resolving the CONSTANT_Fieldref_info entry, The virtual machine checks whether the field ­s access permission enables the current class to access the field. If the field is protected, The virtual machine makes certain the field is a member of the either the current class or a superclass of the current class. If not (or if there is any other access permission problem), The virtual machine throws IllegalAccessError . Else, if the field exists and is accessible from the current class, but the field is not static, The virtual machine throws IncompatibleClassChangeError .

For more information about the putstatic instruction, see Chapter 15, "Objects and Arrays."

ret

- Return from subroutine

Opcode:

169 (0xa9)

Instruction Format:

ret , index

Stack:

No change

Description:

The index operand is an 8-bit unsigned offset into the local variables. The local variable word specified by index must be a returnAddress . To execute the ret instruction, the Java Virtual Machine sets the program counter to the returnAddress value stored in local variable index, and continues execution there. (In other words,

The virtual machine jumps to the returnAddress .)

Note that the wide instruction can precede the ret instruction, to allow a local variable to be accessed with a 16-bit unsigned offset.

For more information about the ret instruction, see Chapter 18, "Finally Clauses."

return

- Return ( void ) from method

Opcode:

177 (0xb1)

Instruction Format:

return

Stack:

Before: ...

After: [empty]

Description:

The return type of the returning method must be void .To execute the return instruction, the Java Virtual Machine discards any words that may still be on the returning method ­s frame. If the returning method is synchronized, the monitor that was acquired when the method was invoked is released. The invoking method ­s frame is made current, and The virtual machine continues execution in the invoking method.

For more information about monitors, see Chapter 20, "Thread Synchronization." For more information about the return instruction, see Chapter 19, "Method Invocation and Return."

saload

- Load short from array

Opcode:

53 (0x35)

Instruction Format:

saload

Stack:

Before: ..., arrayref, index

After: ..., value

Description:

To execute the saload instruction, the Java Virtual Machine first pops two words from the operand stack. The arrayref word must be a reference that refers to an array of short s. The index word must be an int . The virtual machine retrieves from the arrayref array the short value specified by index , sign-extends it to an int , and pushes it onto the operand stack.

If arrayref is null , the Java Virtual Machine throws NullPointerException . Otherwise, if index is not a legal index into the arrayref array, The virtual machine throws ArrayIndexOutOfBoundsException .

For more information about the saload instruction, see Chapter 15, "Objects and Arrays."

sastore

- Store into short array

Opcode:

86 (0x56)

Instruction Format:

sastore

Stack:

Before: ..., array, index, value

After: ...

Description:

To execute the sastore instruction, the Java Virtual Machine first pops three words from the operand stack. The arrayref word must be a reference that refers to an array of short s. The index and value words must be int s. The virtual machine truncates the int value to a short and stores it into the arrayref array location specified by index .

If arrayref is null , the Java Virtual Machine throws NullPointerException . Otherwise, if index is not a legal index into the arrayref array, The virtual machine throws ArrayIndexOutOfBoundsException .

For more information about the sastore instruction, see Chapter 15, "Objects and Arrays."

sipush

- Push 16-bit signed integer

Opcode:

17 (0x11)

Instruction Format:

sipush , byte1 , byte2

Stack:

Before:...

After: ..., value

Description:

To execute the sipush instruction, the Java Virtual Machine first forms an intermediate 16-bit signed integer from byte1 and byte2 by calculating (byte1 8) | byte2 .

The virtual machine then sign-extends the intermediate 16-bit signed integer to an int , and pushes the resulting int value onto the operand stack.

For more information about the sipush instruction, see Chapter 10, "Stack Operations."

swap

- Swap top two stack words

Opcode:

95 (0x5f)

Instruction Format:

swap

Stack:

Before: ..., word2, word1

After: ..., word1, word2

Description:

To execute the swap instruction, the Java Virtual Machine swaps the top two words of the operand stack. Both word1 and word2 must be single-word values.

For more information about the swap instruction, see Chapter 10, "Stack Operations."

tableswitch

- Access jump table by index and jump

Opcode:

170 (0xaa)

Instruction Format:

tableswitch , ...0-3 byte pad... , defaultbyte1 , defaultbyte2 , defaultbyte3 , defaultbyte4 , lowbyte1 , lowbyte2 , lowbyte3 , lowbyte4 , highbyte1 , highbyte2 , highbyte3 , highbyte4 , ...jump offsets...

Stack:

Before:..., index

After: ...

Description:

The tableswitch opcode is followed by zero to three bytes of padding--enough so that the byte immediately following the padding starts at an address that is a multiple of four bytes from the beginning of the method. Each padding byte is a zero. Immediately following the padding is a signed 32-bit default branch offset, default . Following default are two signed 32-bit endpoints of the range of case values embedded in this tableswitch instruction: low , the low endpoint, and high , the high endpoint . The value of low must be less than or equal to the value of high . Following low and high are high - low + 1 signed 32-bit branch offsets--one branch offset for high, one for low, and one for each integer case value in between high and low. These offsets serve as a zero-based jump table. The branch offset for low , the first entry in the jump table, immediately follows the high endpoint value.

The virtual machine calculates all of these signed 32-bit values from the four individual bytes as (byte1 24) | (byte2 16) | (byte3 8) | byte4 .

The top word of the operand stack, index , must be an int . To execute the tableswitch instruction, the Java Virtual Machine pops index off the operand stack, compares it to low and high , and selects a branch offset. If index is less than low and greater than high , The virtual machine selects default as the branch offset. Else, The virtual machine selects the branch offset at position index - low in the jump table. Once it has selected a branch offset, The virtual machine calculates a target (program counter) address by adding the signed branch offset to the address of the tableswitch opcode. The target address must be the address of an opcode within the same method as the tableswitch opcode. The virtual machine jumps to the target address and continues execution there.

For more information about the tableswitch instruction, see Chapter 16, "Control Flow."

wide

- Extend a local variable index with additional bytes

Opcode:

196 (0xc4)

Instruction Format:

wide , <opcode , indexbyte1 , indexbyte2

or

wide , iinc , indexbyte1 , indexbyte2 , constbyte1 , constbyte2

Stack:

To see how the stack changes when an instruction is modified by wide , see the entry for the unmodified instruction. The stack change for an instruction modified by wide is identical to the stack change for that same instruction unmodified.

Description:

The wide opcode modifies instructions that reference the local variables, extending the modified instruction ­s unsigned 8-bit local variable index to an unsigned 16-bit index. As shown above, a wide instruction comes in two formats. When the wide opcode modifies iload , fload , aload , lload , dload , istore , fstore , astore , lstore , dstore , or ret , the instruction has the first format. When the wide opcode modifies iinc , the instruction has the second format.

To execute any wide instruction, the Java Virtual Machine first forms an unsigned 16-bit index into the local variables by calculating (indexbyte1 8) | indexbyte2 . Irrespective of the opcode that wide modifies, the calculated index must be a valid index into the local variables of the current frame. If the wide opcode modifies lload , dload , lstore , or dstore , then one more than the calculated index must also be a valid index into the local variables. Given a valid unsigned 16-bit (wide) local variable index, The virtual machine executes the modified instruction using the wide index.

When a wide opcode modifies an iinc instruction, the format of the iinc instruction changes. An unmodified iinc instruction has two operands, an 8-bit unsigned local variable index , and an 8-bit signed increment const . When modified by wide , however, both the iinc instruction ­s local variable index and its increment are extended by an extra byte. To execute this instruction, The virtual machine forms a signed 16-bit increment by calculating (constbyte1 8) | constbyte2 .

Note that from the perspective of the bytecode verifier, the opcode modified by wide is seen as an operand to the wide opcode. The bytecodes are not allowed to treat opcodes modified by wide independently. For example, it is illegal for a goto instruction to jump directly to an opcode modified by wide .

For more information about the wide instruction, see Chapter 10, "Stack Operations."

Orders Orders Backward   Forward
Comments Comments

 COMPUTING MCGRAW-HILL | Beta Books | Contact Us | Order Information | Online Catalog

Computing McGraw-Hill is an imprint of the McGraw-Hill Professional Book Group.


A Division of the McGraw-Hill Companies
Copyright 1997 The McGraw-Hill Companies. All rights reserved. Any use is subject to the Terms of Use; the corporation also has a comprehensive Privacy Policy governing information we may collect from our customers.


Inside the Java virtual machine
Inside the Java 2 Virtual Machine
ISBN: 0071350934
EAN: 2147483647
Year: 1997
Pages: 28
Authors: Bill Venners

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net