aload_0 0x2a

Pushes the reference in local variable 0.

Opcode
0x2a (42)
Family
Loads
Operands
none
Length
1 byte
Operand stack
… → …, value (reference)
Can throw
nothing at run time (beyond linking errors)
Spec name
aload_<n>

What it does

Pushes the reference in local variable 0.

Slots 0 to 3 each have a one-byte instruction; the general aload takes a one-byte slot number, and wide extends that to two bytes. In an instance method slot 0 holds this, which makes aload_0 one of the most common instructions of all: every field access and every call on this starts with it.

The reference may be null; nothing checks it until the reference is used.

How often javac uses it

In JDK 25.0.5's java.base module, aload_0 appears 145,030 times in 6,703 of its 7,391 classes: 7.4% of all instructions, the 1st most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.getInIfOpen, java.io.BufferedOutputStream.<init>, java.io.BufferedReader.<init>, java.io.BufferedReader$1.<init>.

Examples

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

public Tour() in Tour, compiled by javac 25
3public class Tour {
0aload_0 // this
1invokespecial #1// new Object()

Open in the viewer

public Asserts() in Asserts, compiled by javac 25
2public class Asserts {
0aload_0 // this
1invokespecial #1// new Object()

Open in the viewer

Related instructions

astore_0 Pops a reference into local variable 0.aload Pushes the reference 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, aload_<n> (Java SE 25).