aconst_null 0x01
Pushes null.
- Opcode
0x01(1)- Family
- Constants
- Operands
- none
- Length
- 1 byte
- Operand stack
… → …, null- Can throw
- nothing at run time (beyond linking errors)
What it does
The null literal. Tests against null use ifnull and ifnonnull instead of loading null and comparing.
How often javac uses it
In JDK 25.0.5's java.base module, aconst_null appears 9,304 times in 1,998 of its 7,391 classes: 0.48% of all instructions, the 43rd most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.close, java.io.BufferedReader.readLine, java.io.BufferedReader$1.<init>, java.io.BufferedWriter.close.
Examples
From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; aconst_null is highlighted.
static String cast(Object o) in Tour, compiled by javac 25public Comparable max() in Numbers, compiled by javac 25Related instructions
ifnull Pops a reference; jumps if it is null.ifnonnull Pops a reference; jumps if it is not null.iconst_0 Pushes the int constant 0.
Specification: JVMS §6.5, aconst_null (Java SE 25).