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

TypeFieldWhat it holds
u1tag18
u2bootstrap_method_attr_indexan index into the BootstrapMethods attribute
u2name_and_type_indexa 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:

OffsetBytesFieldValue
1305 bytes#15 InvokeDynamic#0:makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;
13012tag18 (InvokeDynamic)
13100 00bootstrap_method_attr_index0
13300 10name_and_type_index#16

Open in the viewer

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