castore 0x55
Pops an array, an index and a char value; stores the value in the array.
- Opcode
0x55(85)- Family
- Arrays
- Operands
- none
- Length
- 1 byte
- Operand stack
…, arrayref, index, value (int) → …- Can throw
NullPointerException,ArrayIndexOutOfBoundsException
What it does
Pops an array (char[]), an index and a value; stores the value at that index, truncating the int to the element type.
How often javac uses it
In JDK 25.0.5's java.base module, castore appears 1,280 times in 87 of its 7,391 classes: 0.07% of all instructions, the 101st most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedWriter.write, java.io.CharArrayWriter.write, java.io.DataInputStream.readLine, java.io.ObjectInputStream$BlockDataInputStream.readChars.
Example
From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; castore is highlighted.
static int arrays(int n) in Tour, compiled by javac 25Related instructions
caload Pops an array and an index; pushes the char element.arraylength Pops an array; pushes its length.newarray Pops a length; pushes a new array of a primitive type.
Specification: JVMS §6.5, castore (Java SE 25).