ifnonnull 0xc7
Pops a reference; jumps if it is not null.
- Opcode
0xc7(199)- 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 not 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, ifnonnull appears 6,443 times in 1,710 of its 7,391 classes: 0.33% of all instructions, the 55th most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.getInIfOpen, java.io.BufferedReader.ensureOpen, java.io.BufferedReader$1.next, java.io.BufferedWriter.ensureOpen.
Example
From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; ifnonnull is highlighted.
static String cast(Object o) in Tour, compiled by javac 25Related instructions
ifnull Pops a reference; jumps if it is null.if_acmpeq Pops two references; jumps if they are the same object.aconst_null Pushes null.
Specification: JVMS §6.5, ifnonnull (Java SE 25).