ifne 0x9a
Pops an int; jumps if it is not equal to zero.
- Opcode
0x9a(154)- Family
- Branches and switches
- Operands
- 2 bytes: signed branch offset
- Length
- 3 bytes
- Operand stack
…, value (int) → …- Can throw
- nothing at run time (beyond linking errors)
- Spec name
if<cond>
What it does
Pops an int and jumps if it is != 0. The offset is two signed bytes, relative to this instruction.
javac compiles an if statement as a jump past the then-part when the condition is false, so the instruction is usually the opposite of the source: if (x == 0) becomes ifne to the else-part. Booleans are ints, so if (!flag) is ifne too, and so is the test of an instanceof or equals result.
How often javac uses it
In JDK 25.0.5's java.base module, ifne appears 12,832 times in 2,264 of its 7,391 classes: 0.66% of all instructions, the 41st most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.getBufIfOpen, java.io.BufferedReader.read1, java.io.BufferedWriter.flushBuffer, java.io.ByteArrayInputStream.transferTo.
Examples
From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; ifne is highlighted.
static { … } in Asserts, compiled by javac 25static boolean either(boolean a, boolean b) in Conditions, compiled by javac 25Related instructions
ifeq Pops an int; jumps if it is equal to zero.if_icmpne Pops two ints; jumps if the first is not equal to the second.ifnull Pops a reference; jumps if it is null.
Specification: JVMS §6.5, if<cond> (Java SE 25).