imul 0x68
Multiplies two ints on top of the stack; pushes the result.
- Opcode
0x68(104)- Family
- Arithmetic and bitwise
- Operands
- none
- Length
- 1 byte
- Operand stack
…, value1 (int), value2 (int) → …, result (int)- Can throw
- nothing at run time (beyond linking errors)
What it does
a * b on two ints: pops b, then a, and pushes the result.
Overflow wraps around silently, as in Java. Math.multiplyExact is the version that throws.
How often javac uses it
In JDK 25.0.5's java.base module, imul appears 1,140 times in 363 of its 7,391 classes: 0.06% of all instructions, the 105th most common of 194 opcodes in use. Some of the methods that use it: java.io.DataOutputStream.writeChars, java.io.ObjectStreamClass$DeserializationConstructorsCache$Key.hashCode, java.io.ObjectStreamClass$FieldReflectorKey.<init>, java.io.RandomAccessFile.writeChars.
Examples
From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; imul is highlighted.
private static Integer lambda$sumOfSquares$0(Integer x) synthetic in Lambdas, compiled by javac 25double length() in Point, compiled by javac 25Related instructions
lmul Multiplies two longs on top of the stack; pushes the result.fmul Multiplies two floats on top of the stack; pushes the result.dmul Multiplies two doubles on top of the stack; pushes the result.
Specification: JVMS §6.5, imul (Java SE 25).