iflt 0x9b

Pops an int; jumps if it is less than zero.

Opcode
0x9b (155)
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 iflt to the else-part. It also follows lcmp, fcmpl and the other compare instructions, which push an int for it to test.

How often javac uses it

In JDK 25.0.5's java.base module, iflt appears 1,676 times in 590 of its 7,391 classes: 0.09% of all instructions, the 96th most common of 194 opcodes in use. Some of the methods that use it: java.io.CharArrayReader.<init>, java.io.File.getTotalSpace, java.io.FileInputStream.readAllBytes, java.io.InputStream.readNBytes.

Example

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

public Point(int x, int y) in Point, compiled by javac 25
4public Point {
0aload_0 // this
1invokespecial #1// new Record()
5if (x < 0 || y < 0) throw new IllegalArgumentException("negative");
4iload_1 // x
8iload_2 // y
12new #7// IllegalArgumentException
15dup
16ldc #9// "negative"
18invokespecial #11// new IllegalArgumentException(String)
4public Point {
22aload_0 // this
23iload_1 // x
24putfield #14// Point.x : int
27aload_0 // this
28iload_2 // y
29putfield #20// Point.y : int
6}

Open in the viewer

Related instructions

ifge Pops an int; jumps if it is greater than or equal to zero.if_icmplt Pops two ints; jumps if the first is less than the second.lcmp Compares two longs and pushes -1, 0 or 1.

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