iload_3 0x1d

Pushes the int in local variable 3.

Opcode
0x1d (29)
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 3.

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_3 appears 13,244 times in 1,861 of its 7,391 classes: 0.68% of all instructions, the 40th most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.read1, java.io.BufferedOutputStream.<init>, java.io.BufferedReader.read1, 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_3 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 String repeat(String s, int times) in Concat, compiled by javac 25
8String out = "";
0ldc #11// ""
2astore_2 // out
9for (int i = 0; i < times; i++) {
4istore_3 // i
5iload_3 // i
6iload_1 // times
10out += s;
10aload_2 // out
11aload_0 // s
12invokedynamic #13// makeConcatWithConstants(String, String) : String ⇐ StringConcatFactory.makeConcatWithConstants "\1\1"
17astore_2 // out
9for (int i = 0; i < times; i++) {
18iinc 3, 1// i
12return out;
24aload_2 // out

Open in the viewer

Related instructions

istore_3 Pops a int into local variable 3.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).