astore_0 0x4b

Pops a reference into local variable 0.

Opcode
0x4b (75)
Family
Stores
Operands
none
Length
1 byte
Operand stack
…, value (reference) → …
Can throw
nothing at run time (beyond linking errors)
Spec name
astore_<n>

What it does

Pops a reference into local variable 0.

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

astore can also store a return address left by jsr, which only matters for very old class files.

How often javac uses it

In JDK 25.0.5's java.base module, astore_0 appears 1,796 times in 528 of its 7,391 classes: 0.09% of all instructions, the 94th most common of 194 opcodes in use. Some of the methods that use it: java.io.Console.instantiateConsole, java.io.DeleteOnExitHook.runHooks, java.io.File$TempDirectory.generateFile, java.io.FilePermission.initNb.

Example

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

static { … } in EnumSwitch.1, compiled by javac 25
… 5 instructions before
20switch (day) {
12getstatic #13// DayOfWeek.SATURDAY : DayOfWeek
15invokevirtual #17// DayOfWeek.ordinal() : int
23astore_0 catch NoSuchFieldError
24getstatic #7// EnumSwitch$1.$SwitchMap$java$time$DayOfWeek : int[]
27getstatic #23// DayOfWeek.SUNDAY : DayOfWeek
30invokevirtual #17// DayOfWeek.ordinal() : int
35goto 39
… 2 instructions after

Open in the viewer

Related instructions

aload_0 Pushes the reference in local variable 0.astore Pops a reference 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, astore_<n> (Java SE 25).