ifeq 0x99

Pops an int; jumps if it is equal to zero.

Opcode
0x99 (153)
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 ifeq to the else-part. Booleans are ints, so if (flag) is ifeq 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, ifeq appears 21,435 times in 2,796 of its 7,391 classes: 1.1% of all instructions, the 27th most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.getBufIfOpen, java.io.BufferedOutputStream.initialBufferSize, java.io.BufferedReader.fill, java.io.BufferedReader$1.next.

Examples

From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; ifeq is highlighted.

static boolean either(boolean a, boolean b) in Conditions, compiled by javac 25
12return a || b;
0iload_0 // a
4iload_1 // b

Open in the viewer

static int oldStyle(Object o) in InstanceofPattern, compiled by javac 25
12if (o instanceof String) {
0aload_0 // o
1instanceof #7// String
13String s = (String) o;
7aload_0 // o
8checkcast #7// String
11astore_1 // s
14return s.length();
12aload_1 // s
13invokevirtual #13// String.length() : int
16return -1;

Open in the viewer

Related instructions

ifne Pops an int; jumps if it is not equal to zero.if_icmpeq Pops two ints; jumps if the first is equal to the second.ifnull Pops a reference; jumps if it is null.

Specification: JVMS §6.5, if<cond> (Java SE 25).