iastore 0x4f

Pops an array, an index and a int value; stores the value in the array.

Opcode
0x4f (79)
Family
Arrays
Operands
none
Length
1 byte
Operand stack
…, arrayref, index, value (int) → …
Can throw
NullPointerException, ArrayIndexOutOfBoundsException

What it does

Pops an array (int[]), an index and a value; stores the value at that index.

How often javac uses it

In JDK 25.0.5's java.base module, iastore appears 14,312 times in 285 of its 7,391 classes: 0.73% of all instructions, the 38th most common of 194 opcodes in use. Some of the methods that use it: java.io.ObjectInputStream$BlockDataInputStream.readInts, java.io.ObjectInputStream$FieldValues.<init>, java.io.ObjectInputStream$HandleTable$HandleList.add, java.io.ObjectOutputStream$HandleTable.insert.

Examples

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

static int assignElement(int[] a, int v) in Tour, compiled by javac 25
82return a[0] = v;
0aload_0 // a
2iload_1 // v

Open in the viewer

static void array(int[] a, int i) in Increments, compiled by javac 25
22a[i]++;
0aload_0 // a
1iload_1 // i
23}

Open in the viewer

Related instructions

iaload Pops an array and an index; pushes the int element.arraylength Pops an array; pushes its length.newarray Pops a length; pushes a new array of a primitive type.

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