ifnull 0xc6
Pops a reference; jumps if it is null.
- Opcode
0xc6(198)- Family
- Branches and switches
- Operands
- 2 bytes: signed branch offset
- Length
- 3 bytes
- Operand stack
…, value (reference) → …- Can throw
- nothing at run time (beyond linking errors)
What it does
Pops a reference and jumps if it is null. javac uses it for x == null and x != null, usually inverted to skip the then-part.
How often javac uses it
In JDK 25.0.5's java.base module, ifnull appears 9,072 times in 1,699 of its 7,391 classes: 0.46% of all instructions, the 44th most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.read, java.io.BufferedReader.readLine, java.io.BufferedReader$1.hasNext, java.io.BufferedWriter.close.
Example
From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; ifnull is highlighted.
public Comparable max() in Numbers, compiled by javac 25Related instructions
ifnonnull Pops a reference; jumps if it is not null.if_acmpeq Pops two references; jumps if they are the same object.aconst_null Pushes null.
Specification: JVMS §6.5, ifnull (Java SE 25).