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
| Type | Field | What it holds |
|---|---|---|
u1 | tag | 15 |
u1 | reference_kind | 1–9: getField, getStatic, putField, putStatic, invokeVirtual, invokeStatic, invokeSpecial, newInvokeSpecial, invokeInterface |
u2 | reference_index | a 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:
| Offset | Bytes | Field | Value |
|---|---|---|---|
| 536 | 4 bytes | #46 MethodHandle | REF_invokeStatic java/lang/invoke/StringConcatFactory.makeConcatWithCo… |
| 536 | 0f | tag | 15 (MethodHandle) |
| 537 | 06 | reference_kind | 6 (REF_invokeStatic) |
| 538 | 00 2f | reference_index | #47 |
Specification: JVMS §4.4, CONSTANT_MethodHandle_info (Java SE 25).