istore_0 0x3b

Pops a int into local variable 0.

Opcode
0x3b (59)
Family
Stores
Operands
none
Length
1 byte
Operand stack
…, value (int) → …
Can throw
nothing at run time (beyond linking errors)
Spec name
istore_<n>

What it does

Pops an int into local variable 0.

Slots 0 to 3 each have a one-byte instruction; the general istore takes a one-byte slot number, and wide extends that to two bytes.

int locals also hold booleans, bytes, chars and shorts: the JVM has no smaller local variable types.

How often javac uses it

In JDK 25.0.5's java.base module, istore_0 appears 260 times in 82 of its 7,391 classes: 0.01% of all instructions, the 140th most common of 194 opcodes in use. Some of the methods that use it: java.lang.Byte$ByteCache.<clinit>, java.lang.Character$CharacterCache.<clinit>, java.lang.constant.DirectMethodHandleDesc$Kind.<clinit>, java.lang.Integer.toString.

Examples

From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; istore_0 is highlighted.

static int doWhile(int n) in Loops, compiled by javac 25
21int digits = 0;
1istore_1 // digits
23n /= 10;
2iload_0 // n
3bipush 10
6istore_0 // n
24digits++;
7iinc 1, 1// digits
25} while (n != 0);
10iload_0 // n
26return digits;
14iload_1 // digits

Open in the viewer

static long constants() in Tour, compiled by javac 25
129int a = -1, b = 5, c = 100, d = 1000, e = 100000;
1istore_0 // a
3istore_1 // b
4bipush 100
6istore_2 // c
7sipush 1000
10istore_3 // d
… 39 instructions after

Open in the viewer

Related instructions

iload_0 Pushes the int in local variable 0.istore Pops a int into local variable (operand).wide Makes the next instruction take a two-byte local index (and a two-byte iinc constant).

Specification: JVMS §6.5, istore_<n> (Java SE 25).