The JVM instruction set
All 205 opcodes of the Java Virtual Machine: what each does to the operand stack, how it is encoded, how often javac uses it, and a real example of each.
The JVM is a stack machine. Instructions take their inputs from an operand stack and push their results back; local variables, including this and the parameters, live in numbered slots. Each opcode is one byte, and most carry their type in their name: iadd adds ints, dadd doubles, aload loads a reference. byte, short, char and boolean have almost no instructions of their own: on the stack they are ints.
The counts come from parsing every one of the 7,391 classes in JDK 25.0.5's java.base module: 66,382 methods and 1,951,129 instructions. The ten most common are aload_0 (7.4%), dup (7.4%), invokevirtual (6.1%), bipush (4.6%), getfield (3.8%), aastore (3.5%), aload_1 (3.2%), aload (3.1%), ldc_w (2.8%), invokestatic (2.7%). Together they are 44.6% of all bytecode. 8 opcodes are never used at all: nop, fstore_0, swap, frem, jsr, ret, goto_w, jsr_w.
Constants 20
Push a constant onto the operand stack. Small values have their own one-byte instructions; bigger ones come from an operand or the constant pool.
| Hex | Instruction | Stack | What it does | In java.base |
|---|---|---|---|---|
0x01 | aconst_null | … → …, null | Pushes null. | 9,304 |
0x02 | iconst_m1 | … → …, -1 (int) | Pushes the int constant -1. | 3,740 |
0x03 | iconst_0 | … → …, 0 (int) | Pushes the int constant 0. | 45,662 |
0x04 | iconst_1 | … → …, 1 (int) | Pushes the int constant 1. | 39,832 |
0x05 | iconst_2 | … → …, 2 (int) | Pushes the int constant 2. | 20,715 |
0x06 | iconst_3 | … → …, 3 (int) | Pushes the int constant 3. | 6,091 |
0x07 | iconst_4 | … → …, 4 (int) | Pushes the int constant 4. | 5,561 |
0x08 | iconst_5 | … → …, 5 (int) | Pushes the int constant 5. | 3,914 |
0x09 | lconst_0 | … → …, 0 (long) | Pushes the long constant 0. | 2,402 |
0x0a | lconst_1 | … → …, 1 (long) | Pushes the long constant 1. | 987 |
0x0b | fconst_0 | … → …, 0 (float) | Pushes the float constant 0. | 40 |
0x0c | fconst_1 | … → …, 1 (float) | Pushes the float constant 1. | 41 |
0x0d | fconst_2 | … → …, 2 (float) | Pushes the float constant 2. | 10 |
0x0e | dconst_0 | … → …, 0 (double) | Pushes the double constant 0. | 163 |
0x0f | dconst_1 | … → …, 1 (double) | Pushes the double constant 1. | 108 |
0x10 | bipush | … → …, value (int) | Pushes a byte, sign-extended to int. | 89,187 |
0x11 | sipush | … → …, value (int) | Pushes a short, sign-extended to int. | 34,361 |
0x12 | ldc | … → …, value | Pushes a constant from the constant pool (index in one byte). | 41,535 |
0x13 | ldc_w | … → …, value | Pushes a constant from the constant pool (index in two bytes). | 54,903 |
0x14 | ldc2_w | … → …, value (long or double) | Pushes a long or double constant from the constant pool. | 9,670 |
Loads 25
Copy a local variable onto the operand stack. Slots 0 to 3 have one-byte forms; other slots take an operand.
| Hex | Instruction | Stack | What it does | In java.base |
|---|---|---|---|---|
0x15 | iload | … → …, value (int) | Pushes the int in local variable (operand). | 45,311 |
0x16 | lload | … → …, value (long) | Pushes the long in local variable (operand). | 14,779 |
0x17 | fload | … → …, value (float) | Pushes the float in local variable (operand). | 287 |
0x18 | dload | … → …, value (double) | Pushes the double in local variable (operand). | 1,179 |
0x19 | aload | … → …, value (reference) | Pushes the reference in local variable (operand). | 60,166 |
0x1a | iload_0 | … → …, value (int) | Pushes the int in local variable 0. | 3,941 |
0x1b | iload_1 | … → …, value (int) | Pushes the int in local variable 1. | 15,276 |
0x1c | iload_2 | … → …, value (int) | Pushes the int in local variable 2. | 16,309 |
0x1d | iload_3 | … → …, value (int) | Pushes the int in local variable 3. | 13,244 |
0x1e | lload_0 | … → …, value (long) | Pushes the long in local variable 0. | 1,027 |
0x1f | lload_1 | … → …, value (long) | Pushes the long in local variable 1. | 2,828 |
0x20 | lload_2 | … → …, value (long) | Pushes the long in local variable 2. | 3,170 |
0x21 | lload_3 | … → …, value (long) | Pushes the long in local variable 3. | 1,949 |
0x22 | fload_0 | … → …, value (float) | Pushes the float in local variable 0. | 135 |
0x23 | fload_1 | … → …, value (float) | Pushes the float in local variable 1. | 158 |
0x24 | fload_2 | … → …, value (float) | Pushes the float in local variable 2. | 157 |
0x25 | fload_3 | … → …, value (float) | Pushes the float in local variable 3. | 143 |
0x26 | dload_0 | … → …, value (double) | Pushes the double in local variable 0. | 509 |
0x27 | dload_1 | … → …, value (double) | Pushes the double in local variable 1. | 297 |
0x28 | dload_2 | … → …, value (double) | Pushes the double in local variable 2. | 358 |
0x29 | dload_3 | … → …, value (double) | Pushes the double in local variable 3. | 201 |
0x2a | aload_0 | … → …, value (reference) | Pushes the reference in local variable 0. | 145,030 |
0x2b | aload_1 | … → …, value (reference) | Pushes the reference in local variable 1. | 63,228 |
0x2c | aload_2 | … → …, value (reference) | Pushes the reference in local variable 2. | 34,470 |
0x2d | aload_3 | … → …, value (reference) | Pushes the reference in local variable 3. | 22,341 |
Stores 25
Pop the top of the operand stack into a local variable.
| Hex | Instruction | Stack | What it does | In java.base |
|---|---|---|---|---|
0x36 | istore | …, value (int) → … | Pops a int into local variable (operand). | 19,144 |
0x37 | lstore | …, value (long) → … | Pops a long into local variable (operand). | 7,710 |
0x38 | fstore | …, value (float) → … | Pops a float into local variable (operand). | 54 |
0x39 | dstore | …, value (double) → … | Pops a double into local variable (operand). | 491 |
0x3a | astore | …, value (reference) → … | Pops a reference into local variable (operand). | 26,719 |
0x3b | istore_0 | …, value (int) → … | Pops a int into local variable 0. | 260 |
0x3c | istore_1 | …, value (int) → … | Pops a int into local variable 1. | 2,043 |
0x3d | istore_2 | …, value (int) → … | Pops a int into local variable 2. | 4,586 |
0x3e | istore_3 | …, value (int) → … | Pops a int into local variable 3. | 4,445 |
0x3f | lstore_0 | …, value (long) → … | Pops a long into local variable 0. | 86 |
0x40 | lstore_1 | …, value (long) → … | Pops a long into local variable 1. | 340 |
0x41 | lstore_2 | …, value (long) → … | Pops a long into local variable 2. | 576 |
0x42 | lstore_3 | …, value (long) → … | Pops a long into local variable 3. | 484 |
0x43 | fstore_0 | …, value (float) → … | Pops a float into local variable 0. | 0 |
0x44 | fstore_1 | …, value (float) → … | Pops a float into local variable 1. | 7 |
0x45 | fstore_2 | …, value (float) → … | Pops a float into local variable 2. | 6 |
0x46 | fstore_3 | …, value (float) → … | Pops a float into local variable 3. | 19 |
0x47 | dstore_0 | …, value (double) → … | Pops a double into local variable 0. | 26 |
0x48 | dstore_1 | …, value (double) → … | Pops a double into local variable 1. | 17 |
0x49 | dstore_2 | …, value (double) → … | Pops a double into local variable 2. | 62 |
0x4a | dstore_3 | …, value (double) → … | Pops a double into local variable 3. | 36 |
0x4b | astore_0 | …, value (reference) → … | Pops a reference into local variable 0. | 1,796 |
0x4c | astore_1 | …, value (reference) → … | Pops a reference into local variable 1. | 5,553 |
0x4d | astore_2 | …, value (reference) → … | Pops a reference into local variable 2. | 8,282 |
0x4e | astore_3 | …, value (reference) → … | Pops a reference into local variable 3. | 7,267 |
Arrays 20
Create arrays, read and write their elements, and get their length. Every element access checks for null and for an index out of bounds.
| Hex | Instruction | Stack | What it does | In java.base |
|---|---|---|---|---|
0x2e | iaload | …, arrayref, index → …, value (int) | Pops an array and an index; pushes the int element. | 2,558 |
0x2f | laload | …, arrayref, index → …, value (long) | Pops an array and an index; pushes the long element. | 7,327 |
0x30 | faload | …, arrayref, index → …, value (float) | Pops an array and an index; pushes the float element. | 154 |
0x31 | daload | …, arrayref, index → …, value (double) | Pops an array and an index; pushes the double element. | 351 |
0x32 | aaload | …, arrayref, index → …, value (reference) | Pops an array and an index; pushes the reference element. | 8,966 |
0x33 | baload | …, arrayref, index → …, value (int) | Pops an array and an index; pushes the byte or boolean element. | 2,502 |
0x34 | caload | …, arrayref, index → …, value (int) | Pops an array and an index; pushes the char element. | 749 |
0x35 | saload | …, arrayref, index → …, value (int) | Pops an array and an index; pushes the short element. | 164 |
0x4f | iastore | …, arrayref, index, value (int) → … | Pops an array, an index and a int value; stores the value in the array. | 14,312 |
0x50 | lastore | …, arrayref, index, value (long) → … | Pops an array, an index and a long value; stores the value in the array. | 2,949 |
0x51 | fastore | …, arrayref, index, value (float) → … | Pops an array, an index and a float value; stores the value in the array. | 102 |
0x52 | dastore | …, arrayref, index, value (double) → … | Pops an array, an index and a double value; stores the value in the array. | 1,272 |
0x53 | aastore | …, arrayref, index, value (reference) → … | Pops an array, an index and a reference value; stores the value in the array. | 67,452 |
0x54 | bastore | …, arrayref, index, value (int) → … | Pops an array, an index and a byte or boolean value; stores the value in the array. | 22,081 |
0x55 | castore | …, arrayref, index, value (int) → … | Pops an array, an index and a char value; stores the value in the array. | 1,280 |
0x56 | sastore | …, arrayref, index, value (int) → … | Pops an array, an index and a short value; stores the value in the array. | 3,244 |
0xbc | newarray | …, count (int) → …, arrayref | Pops a length; pushes a new array of a primitive type. | 3,063 |
0xbd | anewarray | …, count (int) → …, arrayref | Pops a length; pushes a new array of references. | 19,330 |
0xbe | arraylength | …, arrayref → …, length (int) | Pops an array; pushes its length. | 6,694 |
0xc5 | multianewarray | …, count1, count2, … → …, arrayref | Pops several lengths; pushes a new multi-dimensional array. | 17 |
Stack manipulation 9
Discard, duplicate and swap values on the operand stack without looking at their types. Long and double values take two slots, which is why the dup2 forms exist.
| Hex | Instruction | Stack | What it does | In java.base |
|---|---|---|---|---|
0x57 | pop | …, value → … | Discards the top stack slot. | 15,497 |
0x58 | pop2 | …, value2, value1 → … | Discards the top two stack slots (or one long or double). | 130 |
0x59 | dup | …, value → …, value, value | Duplicates the top of the stack. | 144,789 |
0x5a | dup_x1 | …, value2, value1 → …, value1, value2, value1 | Duplicates the top value and inserts it two slots down. | 868 |
0x5b | dup_x2 | …, value3, value2, value1 → …, value1, value3, value2, value1 | Duplicates the top value and inserts it three slots down. | 57 |
0x5c | dup2 | …, value2, value1 → …, value2, value1, value2, value1 | Duplicates the top two slots (or one long or double). | 1,462 |
0x5d | dup2_x1 | …, value3, value2, value1 → …, value2, value1, value3, value2, value1 | Duplicates the top two slots and inserts them three slots down. | 34 |
0x5e | dup2_x2 | …, value4, value3, value2, value1 → …, value2, value1, value4, value3, value2, value1 | Duplicates the top two slots and inserts them four slots down. | 1 |
0x5f | swap | …, value2, value1 → …, value1, value2 | Swaps the top two values. | 0 |
Arithmetic and bitwise 37
Arithmetic, shifts and bitwise operations on int, long, float and double. There are no byte, short, char or boolean versions: those values are ints on the stack.
| Hex | Instruction | Stack | What it does | In java.base |
|---|---|---|---|---|
0x60 | iadd | …, value1 (int), value2 (int) → …, result (int) | Adds two ints on top of the stack; pushes the result. | 8,545 |
0x61 | ladd | …, value1 (long), value2 (long) → …, result (long) | Adds two longs on top of the stack; pushes the result. | 7,549 |
0x62 | fadd | …, value1 (float), value2 (float) → …, result (float) | Adds two floats on top of the stack; pushes the result. | 10 |
0x63 | dadd | …, value1 (double), value2 (double) → …, result (double) | Adds two doubles on top of the stack; pushes the result. | 296 |
0x64 | isub | …, value1 (int), value2 (int) → …, result (int) | Subtracts two ints on top of the stack; pushes the result. | 6,194 |
0x65 | lsub | …, value1 (long), value2 (long) → …, result (long) | Subtracts two longs on top of the stack; pushes the result. | 1,631 |
0x66 | fsub | …, value1 (float), value2 (float) → …, result (float) | Subtracts two floats on top of the stack; pushes the result. | 3 |
0x67 | dsub | …, value1 (double), value2 (double) → …, result (double) | Subtracts two doubles on top of the stack; pushes the result. | 255 |
0x68 | imul | …, value1 (int), value2 (int) → …, result (int) | Multiplies two ints on top of the stack; pushes the result. | 1,140 |
0x69 | lmul | …, value1 (long), value2 (long) → …, result (long) | Multiplies two longs on top of the stack; pushes the result. | 4,632 |
0x6a | fmul | …, value1 (float), value2 (float) → …, result (float) | Multiplies two floats on top of the stack; pushes the result. | 43 |
0x6b | dmul | …, value1 (double), value2 (double) → …, result (double) | Multiplies two doubles on top of the stack; pushes the result. | 466 |
0x6c | idiv | …, value1 (int), value2 (int) → …, result (int) | Divides two ints on top of the stack; pushes the result. | 485 |
0x6d | ldiv | …, value1 (long), value2 (long) → …, result (long) | Divides two longs on top of the stack; pushes the result. | 266 |
0x6e | fdiv | …, value1 (float), value2 (float) → …, result (float) | Divides two floats on top of the stack; pushes the result. | 10 |
0x6f | ddiv | …, value1 (double), value2 (double) → …, result (double) | Divides two doubles on top of the stack; pushes the result. | 96 |
0x70 | irem | …, value1 (int), value2 (int) → …, result (int) | Takes the remainder of two ints on top of the stack; pushes the result. | 326 |
0x71 | lrem | …, value1 (long), value2 (long) → …, result (long) | Takes the remainder of two longs on top of the stack; pushes the result. | 173 |
0x72 | frem | …, value1 (float), value2 (float) → …, result (float) | Takes the remainder of two floats on top of the stack; pushes the result. | 0 |
0x73 | drem | …, value1 (double), value2 (double) → …, result (double) | Takes the remainder of two doubles on top of the stack; pushes the result. | 1 |
0x74 | ineg | …, value (int) → …, result (int) | Negates the int on top of the stack. | 279 |
0x75 | lneg | …, value (long) → …, result (long) | Negates the long on top of the stack. | 157 |
0x76 | fneg | …, value (float) → …, result (float) | Negates the float on top of the stack. | 7 |
0x77 | dneg | …, value (double) → …, result (double) | Negates the double on top of the stack. | 47 |
0x78 | ishl | …, value1 (int), value2 (int) → …, result (int) | Shifts left two ints on top of the stack; pushes the result. | 1,122 |
0x79 | lshl | …, value1 (long), value2 (int) → …, result (long) | Shifts left two longs on top of the stack; pushes the result. | 2,125 |
0x7a | ishr | …, value1 (int), value2 (int) → …, result (int) | Arithmetic-shifts right two ints on top of the stack; pushes the result. | 973 |
0x7b | lshr | …, value1 (long), value2 (int) → …, result (long) | Arithmetic-shifts right two longs on top of the stack; pushes the result. | 1,536 |
0x7c | iushr | …, value1 (int), value2 (int) → …, result (int) | Logical-shifts right two ints on top of the stack; pushes the result. | 861 |
0x7d | lushr | …, value1 (long), value2 (int) → …, result (long) | Logical-shifts right two longs on top of the stack; pushes the result. | 429 |
0x7e | iand | …, value1 (int), value2 (int) → …, result (int) | Bitwise ANDs two ints on top of the stack; pushes the result. | 3,706 |
0x7f | land | …, value1 (long), value2 (long) → …, result (long) | Bitwise ANDs two longs on top of the stack; pushes the result. | 1,718 |
0x80 | ior | …, value1 (int), value2 (int) → …, result (int) | Bitwise ORs two ints on top of the stack; pushes the result. | 2,115 |
0x81 | lor | …, value1 (long), value2 (long) → …, result (long) | Bitwise ORs two longs on top of the stack; pushes the result. | 397 |
0x82 | ixor | …, value1 (int), value2 (int) → …, result (int) | Bitwise XORs two ints on top of the stack; pushes the result. | 998 |
0x83 | lxor | …, value1 (long), value2 (long) → …, result (long) | Bitwise XORs two longs on top of the stack; pushes the result. | 317 |
0x84 | iinc | … → … | Adds a signed constant to an int local variable, without touching the stack. | 7,076 |
Conversions 15
Convert the value on top of the stack between primitive types: widening (int to long), narrowing (double to int) and the int-to-small-type casts.
| Hex | Instruction | Stack | What it does | In java.base |
|---|---|---|---|---|
0x85 | i2l | …, value (int) → …, result (long) | Converts the int on top of the stack to long. | 3,037 |
0x86 | i2f | …, value (int) → …, result (float) | Converts the int on top of the stack to float. | 65 |
0x87 | i2d | …, value (int) → …, result (double) | Converts the int on top of the stack to double. | 92 |
0x88 | l2i | …, value (long) → …, result (int) | Converts the long on top of the stack to int. | 963 |
0x89 | l2f | …, value (long) → …, result (float) | Converts the long on top of the stack to float. | 14 |
0x8a | l2d | …, value (long) → …, result (double) | Converts the long on top of the stack to double. | 72 |
0x8b | f2i | …, value (float) → …, result (int) | Converts the float on top of the stack to int. | 39 |
0x8c | f2l | …, value (float) → …, result (long) | Converts the float on top of the stack to long. | 5 |
0x8d | f2d | …, value (float) → …, result (double) | Converts the float on top of the stack to double. | 29 |
0x8e | d2i | …, value (double) → …, result (int) | Converts the double on top of the stack to int. | 45 |
0x8f | d2l | …, value (double) → …, result (long) | Converts the double on top of the stack to long. | 33 |
0x90 | d2f | …, value (double) → …, result (float) | Converts the double on top of the stack to float. | 12 |
0x91 | i2b | …, value (int) → …, result (int) | Converts the int on top of the stack to byte. | 2,036 |
0x92 | i2c | …, value (int) → …, result (int) | Converts the int on top of the stack to char. | 443 |
0x93 | i2s | …, value (int) → …, result (int) | Converts the int on top of the stack to short. | 229 |
Comparisons 5
Compare two longs, floats or doubles and push -1, 0 or 1. An int branch then tests the result: there is no single "branch if long less than" instruction.
| Hex | Instruction | Stack | What it does | In java.base |
|---|---|---|---|---|
0x94 | lcmp | …, value1 (long), value2 (long) → …, result (int) | Compares two longs and pushes -1, 0 or 1. | 3,104 |
0x95 | fcmpl | …, value1 (float), value2 (float) → …, result (int) | Compares two floats and pushes -1, 0 or 1; NaN gives -1. | 65 |
0x96 | fcmpg | …, value1 (float), value2 (float) → …, result (int) | Compares two floats and pushes -1, 0 or 1; NaN gives 1. | 59 |
0x97 | dcmpl | …, value1 (double), value2 (double) → …, result (int) | Compares two doubles and pushes -1, 0 or 1; NaN gives -1. | 162 |
0x98 | dcmpg | …, value1 (double), value2 (double) → …, result (int) | Compares two doubles and pushes -1, 0 or 1; NaN gives 1. | 92 |
Branches and switches 23
Conditional and unconditional jumps, and the two switch instructions. Branch offsets are relative to the branch instruction's own address.
| Hex | Instruction | Stack | What it does | In java.base |
|---|---|---|---|---|
0x99 | ifeq | …, value (int) → … | Pops an int; jumps if it is equal to zero. | 21,435 |
0x9a | ifne | …, value (int) → … | Pops an int; jumps if it is not equal to zero. | 12,832 |
0x9b | iflt | …, value (int) → … | Pops an int; jumps if it is less than zero. | 1,676 |
0x9c | ifge | …, value (int) → … | Pops an int; jumps if it is greater than or equal to zero. | 2,002 |
0x9d | ifgt | …, value (int) → … | Pops an int; jumps if it is greater than zero. | 702 |
0x9e | ifle | …, value (int) → … | Pops an int; jumps if it is less than or equal to zero. | 2,075 |
0x9f | if_icmpeq | …, value1 (int), value2 (int) → … | Pops two ints; jumps if the first is equal to the second. | 3,295 |
0xa0 | if_icmpne | …, value1 (int), value2 (int) → … | Pops two ints; jumps if the first is not equal to the second. | 5,147 |
0xa1 | if_icmplt | …, value1 (int), value2 (int) → … | Pops two ints; jumps if the first is less than the second. | 1,917 |
0xa2 | if_icmpge | …, value1 (int), value2 (int) → … | Pops two ints; jumps if the first is greater than or equal to the second. | 5,779 |
0xa3 | if_icmpgt | …, value1 (int), value2 (int) → … | Pops two ints; jumps if the first is greater than the second. | 1,231 |
0xa4 | if_icmple | …, value1 (int), value2 (int) → … | Pops two ints; jumps if the first is less than or equal to the second. | 2,267 |
0xa5 | if_acmpeq | …, value1 (reference), value2 (reference) → … | Pops two references; jumps if they are the same object. | 1,418 |
0xa6 | if_acmpne | …, value1 (reference), value2 (reference) → … | Pops two references; jumps if they are different objects. | 2,945 |
0xa7 | goto | … → … | Jumps unconditionally. | 35,040 |
0xa8 | jsr | … → …, address | Jumps to a subroutine, pushing the return address (old finally blocks; not allowed since Java 7 class files). | 0 |
0xa9 | ret | … → … | Returns from a subroutine to the address in a local variable. | 0 |
0xaa | tableswitch | …, index (int) → … | Jumps through a table indexed by an int (dense case values). | 659 |
0xab | lookupswitch | …, key (int) → … | Jumps through sorted match/offset pairs (sparse case values). | 497 |
0xc6 | ifnull | …, value (reference) → … | Pops a reference; jumps if it is null. | 9,072 |
0xc7 | ifnonnull | …, value (reference) → … | Pops a reference; jumps if it is not null. | 6,443 |
0xc8 | goto_w | … → … | Jumps unconditionally (four-byte offset). | 0 |
0xc9 | jsr_w | … → …, address | Jumps to a subroutine (four-byte offset). | 0 |
Returns 6
Return from the current method, with a value of the method's return type or with none.
| Hex | Instruction | Stack | What it does | In java.base |
|---|---|---|---|---|
0xac | ireturn | …, value (int) → …, (empty: the frame is gone) | Returns the int on top of the stack from the method. | 17,614 |
0xad | lreturn | …, value (long) → …, (empty: the frame is gone) | Returns the long on top of the stack from the method. | 1,825 |
0xae | freturn | …, value (float) → …, (empty: the frame is gone) | Returns the float on top of the stack from the method. | 305 |
0xaf | dreturn | …, value (double) → …, (empty: the frame is gone) | Returns the double on top of the stack from the method. | 608 |
0xb0 | areturn | …, value (reference) → …, (empty: the frame is gone) | Returns the reference on top of the stack from the method. | 32,175 |
0xb1 | return | … → …, (empty: the frame is gone) | Returns from a void method. | 21,097 |
Fields 4
Read and write static and instance fields, named by a Fieldref constant.
| Hex | Instruction | Stack | What it does | In java.base |
|---|---|---|---|---|
0xb2 | getstatic | … → …, value | Pushes the value of a static field. | 43,153 |
0xb3 | putstatic | …, value → … | Pops a value into a static field. | 8,609 |
0xb4 | getfield | …, objectref → …, value | Pops an object; pushes the value of one of its fields. | 73,588 |
0xb5 | putfield | …, objectref, value → … | Pops an object and a value; stores the value in the field. | 24,204 |
Method calls 5
The five ways to call a method. Arguments are popped from the operand stack, receiver first; the result, if any, is pushed.
| Hex | Instruction | Stack | What it does | In java.base |
|---|---|---|---|---|
0xb6 | invokevirtual | …, objectref, arg1, … → …, result | Calls an instance method, chosen by the receiver's class. | 118,921 |
0xb7 | invokespecial | …, objectref, arg1, … → …, result | Calls a constructor, a private method or a superclass method directly. | 43,732 |
0xb8 | invokestatic | …, arg1, … → …, result | Calls a static method. | 52,122 |
0xb9 | invokeinterface | …, objectref, arg1, … → …, result | Calls an interface method, chosen by the receiver's class. | 25,892 |
0xba | invokedynamic | …, arg1, … → …, result | Calls through a call site that a bootstrap method links on first use (lambdas, string concatenation, records, pattern switches). | 2,330 |
Objects and types 4
Allocate objects, test and check their types, and throw them.
| Hex | Instruction | Stack | What it does | In java.base |
|---|---|---|---|---|
0xbb | new | … → …, objectref (uninitialised) | Allocates an object (uninitialised until its constructor runs). | 33,545 |
0xbf | athrow | …, objectref → …, objectref | Throws the exception on top of the stack. | 16,191 |
0xc0 | checkcast | …, objectref → …, objectref | Checks that the reference on top of the stack is of a type (throws ClassCastException if not). | 14,072 |
0xc1 | instanceof | …, objectref → …, result (int) | Pops a reference; pushes 1 if it is of a type, else 0. | 2,895 |
Monitors 2
Lock and unlock an object's monitor: the bytecode behind synchronized blocks.
| Hex | Instruction | Stack | What it does | In java.base |
|---|---|---|---|---|
0xc2 | monitorenter | …, objectref → … | Pops an object and locks its monitor (start of synchronized). | 959 |
0xc3 | monitorexit | …, objectref → … | Pops an object and unlocks its monitor. | 2,147 |
Other 5
An instruction that does nothing, the wide prefix, and the opcodes reserved for debuggers and JVM internals.
| Hex | Instruction | Stack | What it does | In java.base |
|---|---|---|---|---|
0x00 | nop | … → … | Does nothing. | 0 |
0xc4 | wide | … → … | Makes the next instruction take a two-byte local index (and a two-byte iinc constant). | 34 |
0xca | breakpoint | … → … | Reserved for debuggers and JVM internals; never valid in a class file. | 0 |
0xfe | impdep1 | … → … | Reserved for debuggers and JVM internals; never valid in a class file. | 0 |
0xff | impdep2 | … → … | Reserved for debuggers and JVM internals; never valid in a class file. | 0 |