CONSTANT_InvokeDynamic tag 18
A call site for invokedynamic: which bootstrap method links it and the call's name and type.
- Tag
18- Since
- class file 51.0 (Java 7)
- Size
- 5 bytes
- Loadable
- no
- Referred to by
- invokedynamic
Layout
| Type | Field | What it holds |
|---|---|---|
u1 | tag | 18 |
u2 | bootstrap_method_attr_index | an index into the BootstrapMethods attribute |
u2 | name_and_type_index | a NameAndType: the call's name and method descriptor |
What it is for
A call site for invokedynamic: which bootstrap method links it and the call's name and type. The name is only a hint to the bootstrap method: makeConcatWithConstants, toString, typeSwitch, or the lambda's interface method.
The descriptor's parameters are what the call pops from the stack: a capturing lambda takes the captured values, and the return type is the functional interface.
How common it is
JDK 25.0.5's java.base has 2,143 InvokeDynamic constants in 651 of its 7,391 classes: 0.20% of all 1,059,609 constants.
A real one, byte by byte
Constant #15 of Hello.class, compiled by javac 25:
| Offset | Bytes | Field | Value |
|---|---|---|---|
| 130 | 5 bytes | #15 InvokeDynamic | #0:makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String; |
| 130 | 12 | tag | 18 (InvokeDynamic) |
| 131 | 00 00 | bootstrap_method_attr_index | 0 |
| 133 | 00 10 | name_and_type_index | #16 |
Specification: JVMS §4.4, CONSTANT_InvokeDynamic_info (Java SE 25).