putstatic 0xb3
Pops a value into a static field.
- Opcode
0xb3(179)- Family
- Fields
- Operands
- 2 bytes: constant pool index
- Length
- 3 bytes
- Operand stack
…, value → …- Can throw
- nothing at run time (beyond linking errors)
What it does
Pops a value into a static field. Most putstatics are in <clinit>, the static initialiser, which javac assembles from every static field initialiser and static block in source order.
A final static field may only be written from its own class's initialiser.
How often javac uses it
In JDK 25.0.5's java.base module, putstatic appears 8,609 times in 2,101 of its 7,391 classes: 0.44% of all instructions, the 46th most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.<clinit>, java.io.ByteArrayInputStream.<clinit>, java.io.Console.<clinit>, java.io.DataInputStream.<clinit>.
Examples
From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; putstatic is highlighted.
static { … } in Constants, compiled by javac 25static final int COMPUTED = Integer.parseInt("7");static long staticLong() in Increments, compiled by javac 25Related instructions
getstatic Pushes the value of a static field.getfield Pops an object; pushes the value of one of its fields.putfield Pops an object and a value; stores the value in the field.
Specification: JVMS §6.5, putstatic (Java SE 25).