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 25static long mix(long a, int b, short c, byte d, double e, float f, char g, boolean h) in Numbers, compiled by javac 25Related 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).