i2l 0x85
Converts the int on top of the stack to long.
- Opcode
0x85(133)- Family
- Conversions
- Operands
- none
- Length
- 1 byte
- Operand stack
…, value (int) → …, result (long)- Can throw
- nothing at run time (beyond linking errors)
What it does
Converts the int on top of the stack to long.
A widening conversion: javac emits it wherever Java converts implicitly, such as assigning an int to a long or passing an int where a double is expected.
How often javac uses it
In JDK 25.0.5's java.base module, i2l appears 3,037 times in 494 of its 7,391 classes: 0.16% of all instructions, the 74th 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.transferTo, 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; i2l is highlighted.
static double convert(int i, long l, float f, double d) 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
i2f Converts the int on top of the stack to float.i2d Converts the int on top of the stack to double.f2l Converts the float on top of the stack to long.
Specification: JVMS §6.5, i2l (Java SE 25).