ldc2_w 0x14
Pushes a long or double constant from the constant pool.
- Opcode
0x14(20)- Family
- Constants
- Operands
- 2 bytes: constant pool index
- Length
- 3 bytes
- Operand stack
… → …, value (long or double)- Can throw
- nothing at run time (beyond linking errors)
What it does
Pushes a Long or Double constant from the constant pool, taking two stack slots. There is no one-byte-index form: long and double constants always use ldc2_w.
Only values other than 0L, 1L, 0.0 and 1.0 need it; those have lconst_* and dconst_*.
How often javac uses it
In JDK 25.0.5's java.base module, ldc2_w appears 9,670 times in 562 of its 7,391 classes: 0.50% of all instructions, the 42nd most common of 194 opcodes in use. Some of the methods that use it: java.io.BufferedInputStream.transferTo, java.io.File.getTotalSpace, java.io.FileDescriptor.<init>, java.io.FileInputStream.traceRead0.
Examples
From the sample classes, compiled by javac 25 with -g. Each Java line is shown above the bytecode it compiled to; ldc2_w is highlighted.
static double doubles(double a, double b) in Tour, compiled by javac 25static double area(Shapes$Shape s) in Shapes, compiled by javac 25Related instructions
lconst_0 Pushes the long constant 0.dconst_0 Pushes the double constant 0.ldc Pushes a constant from the constant pool (index in one byte).
Specification: JVMS §6.5, ldc2_w (Java SE 25).