l2i 0x88

Converts the long on top of the stack to int.

Opcode
0x88 (136)
Family
Conversions
Operands
none
Length
1 byte
Operand stack
…, value (long) → …, result (int)
Can throw
nothing at run time (beyond linking errors)

What it does

Converts the long on top of the stack to int.

A narrowing conversion: javac emits it only for an explicit cast. It keeps the low 32 bits, so large values change sign or magnitude.

How often javac uses it

In JDK 25.0.5's java.base module, l2i appears 963 times in 266 of its 7,391 classes: 0.05% of all instructions, the 111th most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.skip, java.io.BufferedReader.skip, java.io.ByteArrayInputStream.skip, java.io.CharArrayReader.skip.

Examples

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

static int locals(int a, int b, int c, int d, long e, double f) in Tour, compiled by javac 25
123int g = a + b + c + d;
0iload_0 // a
1iload_1 // b
3iload_2 // c
5iload_3 // d
7istore 8// g
124return g + (int) e + (int) f;
9iload 8// g
11lload 4// e
13l2i
14iadd
15dload 6// f
17d2i
18iadd

Open in the viewer

static long mix(long a, int b, short c, byte d, double e, float f, char g, boolean h) in Numbers, compiled by javac 25
… 33 instructions before
35grid[1][2] = (int) r;
51aload 12// grid
56lload 10// r
58l2i
36Object[] objs = new Object[2];
61anewarray #2// Object
64astore 13// objs
37objs[0] = "x";
66aload 13// objs
… 24 instructions after

Open in the viewer

Related instructions

l2f Converts the long on top of the stack to float.l2d Converts the long on top of the stack to double.f2i Converts the float on top of the stack to int.

Specification: JVMS §6.5, l2i (Java SE 25).