CONSTANT_MethodHandle tag 15

A handle to a field or method, with a kind that says how to use it.

Tag
15
Since
class file 51.0 (Java 7)
Size
4 bytes
Loadable
yes, with ldc, ldc_w
Referred to by
  • BootstrapMethods (every bootstrap method is one)
  • bootstrap method arguments
  • ldc

Layout

TypeFieldWhat it holds
u1tag15
u1reference_kind1–9: getField, getStatic, putField, putStatic, invokeVirtual, invokeStatic, invokeSpecial, newInvokeSpecial, invokeInterface
u2reference_indexa Fieldref, Methodref or InterfaceMethodref, depending on the kind

What it is for

A handle to a field or method, with a kind that says how to use it. Every bootstrap method is a MethodHandle, almost always REF_invokeStatic.

A lambda's bootstrap arguments include another MethodHandle: the synthetic lambda$ method or the method reference's target.

How common it is

JDK 25.0.5's java.base has 2,634 MethodHandle constants in 651 of its 7,391 classes: 0.25% of all 1,059,609 constants.

A real one, byte by byte

Constant #46 of Hello.class, compiled by javac 25:

OffsetBytesFieldValue
5364 bytes#46 MethodHandleREF_invokeStatic java/lang/invoke/StringConcatFactory.makeConcatWithCo…
5360ftag15 (MethodHandle)
53706reference_kind6 (REF_invokeStatic)
53800 2freference_index#47

Open in the viewer

Specification: JVMS §4.4, CONSTANT_MethodHandle_info (Java SE 25).