istore 0x36

Pops a int into local variable (operand).

Opcode
0x36 (54)
Family
Stores
Operands
  • 1 byte: local variable index
Length
2 bytes
Operand stack
…, value (int) → …
Can throw
nothing at run time (beyond linking errors)

What it does

Pops an int into the local variable named by its operand.

Slots 0 to 3 have one-byte forms (istore_0 to istore_3); javac uses this form for slots 4 to 255, and wide for slots above 255.

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 appears 19,144 times in 1,633 of its 7,391 classes: 0.98% of all instructions, the 31st most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.read1, java.io.BufferedOutputStream.growIfNeeded, java.io.BufferedReader.read1, java.io.BufferedWriter.write.

Examples

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

static int locals(int a, int b, int c, int d, long e, double f) in Tour, compiled by javac 25
123int g = a + b + c + d;
0iload_0 // a
1iload_1 // b
3iload_2 // c
5iload_3 // d
7istore 8// g
124return g + (int) e + (int) f;
9iload 8// g
11lload 4// e
13l2i
14iadd
15dload 6// f
17d2i
18iadd

Open in the viewer

static int sum(int[] values) in ForEach, compiled by javac 25
… 3 instructions before
7for (int v : values) {
10iload 4
17iload 4
… 9 instructions after

Open in the viewer

Related instructions

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

Specification: JVMS §6.5, istore (Java SE 25).