iload_2 0x1c

Pushes the int in local variable 2.

Opcode
0x1c (28)
Family
Loads
Operands
none
Length
1 byte
Operand stack
… → …, value (int)
Can throw
nothing at run time (beyond linking errors)
Spec name
iload_<n>

What it does

Pushes the int in local variable 2.

Slots 0 to 3 each have a one-byte instruction; the general iload 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, iload_2 appears 16,309 times in 2,233 of its 7,391 classes: 0.84% of all instructions, the 33rd most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.<init>, java.io.BufferedOutputStream.<init>, java.io.BufferedReader.<init>, java.io.BufferedWriter.<init>.

Examples

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

private Size(String, int) in EnumSwitch.Size, compiled by javac 25
6enum Size { SMALL, MEDIUM, LARGE }
0aload_0 // this
3invokespecial #28// new Enum(String, int)

Open in the viewer

private Color(String, int) in Switches.Color, compiled by javac 25
6enum Color { RED, GREEN, BLUE }
0aload_0 // this
3invokespecial #28// new Enum(String, int)

Open in the viewer

Related instructions

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

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