caload 0x34

Pops an array and an index; pushes the char element.

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

What it does

Pops an array (char[]) and an index; pushes the element at that index, widened to int with zero extension.

How often javac uses it

In JDK 25.0.5's java.base module, caload appears 749 times in 116 of its 7,391 classes: 0.04% of all instructions, the 115th most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedReader.read, java.io.CharArrayReader.read, java.io.FilePermission.getMask, java.io.LineNumberReader.read.

Example

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

static int arrays(int n) in Tour, compiled by javac 25
… 81 instructions before
69return (z[0] ? 1 : 0) + b[0] + c[0] + s[0] + i[0] + (int) l[0] + (int) f[0] + (int) d[0] + str[0].length() + grid[0][0] + grid.length;
121baload
122iadd
123aload_3 // c
125caload
126iadd
127aload 4// s
130saload
131iadd
132aload 5// i
… 33 instructions after

Open in the viewer

Related instructions

castore Pops an array, an index and a char value; stores the value in the array.arraylength Pops an array; pushes its length.newarray Pops a length; pushes a new array of a primitive type.

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