if_icmpgt 0xa3

Pops two ints; jumps if the first is greater than the second.

Opcode
0xa3 (163)
Family
Branches and switches
Operands
  • 2 bytes: signed branch offset
Length
3 bytes
Operand stack
…, value1 (int), value2 (int) → …
Can throw
nothing at run time (beyond linking errors)
Spec name
if_icmp<cond>

What it does

Pops two ints and jumps if the first is > the second.

As with every branch, javac tends to emit the opposite of the source condition and jump past the body. A loop such as for (int i = 0; i < n; i++) tests if_icmpge at the top to leave the loop, and ends with a goto back to the test.

How often javac uses it

In JDK 25.0.5's java.base module, if_icmpgt appears 1,231 times in 436 of its 7,391 classes: 0.06% of all instructions, the 103rd most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedReader.fill, java.io.CharArrayReader.<init>, java.io.DataOutputStream.writeUTF, java.io.File$TempDirectory.generateFile.

Examples

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

static String describe(Object o) in PatternSwitch, compiled by javac 25
… 11 instructions before
7case Integer i when i > 100 -> "a big int";
46checkcast #13// Integer
49astore_3 // i
50aload_3 // i
51invokevirtual #15// Integer.intValue() : int
54bipush 100
61goto 4
64ldc #19// "a big int"
66goto 109
8case Integer i -> "the int " + i;
… 15 instructions after

Open in the viewer

static String describe(Object o) in Shapes, compiled by javac 25
… 22 instructions before
18case Integer i when i > 10 -> "big int";
69checkcast #68// Integer
72astore_3 // i
73aload_3 // i
74invokevirtual #70// Integer.intValue() : int
77bipush 10
84goto 33
87ldc #73// "big int"
89goto 113
19case Integer i -> "int";
… 9 instructions after

Open in the viewer

Related instructions

if_icmple Pops two ints; jumps if the first is less than or equal to the second.ifgt Pops an int; jumps if it is greater than zero.goto Jumps unconditionally.

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