ldc_w 0x13

Pushes a constant from the constant pool (index in two bytes).

Opcode
0x13 (19)
Family
Constants
Operands
  • 2 bytes: constant pool index
Length
3 bytes
Operand stack
… → …, value
Can throw
nothing at run time (beyond linking errors)

What it does

Pushes a constant from the constant pool: an Integer, Float or String; a Class (Java 5 and later, for Foo.class); a MethodType or MethodHandle (Java 7); or a Dynamic constant (Java 11). Strings come back interned: every ldc of the same String constant pushes the same object.

The same as ldc with a two-byte index, for constants past index 255. Large classes with many strings use it constantly.

How often javac uses it

In JDK 25.0.5's java.base module, ldc_w appears 54,903 times in 528 of its 7,391 classes: 2.8% of all instructions, the 9th most common of 194 opcodes in use. Some of the methods that use it: java.io.File.setLastModified, java.io.FilePermission.getMask, java.io.ObjectInputStream.setObjectInputFilter, java.io.ObjectOutputStream.writeObject0.

Related instructions

ldc Pushes a constant from the constant pool (index in one byte).ldc2_w Pushes a long or double constant from the constant pool.bipush Pushes a byte, sign-extended to int.

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