BootstrapMethods attribute

The bootstrap methods that link invokedynamic call sites and compute Dynamic constants, each a MethodHandle with a list of static arguments from the constant pool..

Appears on
class
Since
class file 51.0 (Java 7)
javac writes it
whenever the class uses invokedynamic or a Dynamic constant
Needed by the JVM
yes: the JVM reads it to load, verify or run the class

Layout

TypeFieldWhat it holds
u2attribute_name_indexa Utf8: "BootstrapMethods"
u4attribute_lengthbytes after this field
u2num_bootstrap_methods
{u2,u2,u2[]}[…]bootstrap_methodsbootstrap_method_ref, num_bootstrap_arguments, bootstrap_arguments

What it is for

The bootstrap methods that link invokedynamic call sites and compute Dynamic constants, each a MethodHandle with a list of static arguments from the constant pool.

A lambda's entry points at LambdaMetafactory.metafactory, with arguments for the interface method's type, the implementation method and the instantiated type. A string concatenation's points at StringConcatFactory.makeConcatWithConstants, with a recipe string in which \u0001 marks where each argument goes.

How common it is

JDK 25.0.5's java.base has 651 BootstrapMethods attributes, in 651 of its 7,391 classes (651 on classs).

A real one, byte by byte

From Hello.class (compiled by javac 25), on the class:

OffsetBytesFieldValue
104714 bytesBootstrapMethods
104700 2battribute_name_index#43
104900 00 00 08attribute_length8
105300 01num_bootstrap_methods1
10556 bytesbootstrap method 0
105500 2ebootstrap_method_ref#46
105700 01num_bootstrap_arguments1
105900 2cbootstrap_argument#44

Open in the viewer

Specification: JVMS §4.7, The BootstrapMethods Attribute (Java SE 25).