The BootstrapMethods attribute is a variable-length attribute in the attributes table of a ClassFile structure (§4.1). The BootstrapMethods attribute records bootstrap methods used to produce dynamically-computed constants and dynamically-computed call sites (§4.4.10).
There must be exactly one BootstrapMethods attribute in the attributes table of a ClassFile structure if the constant_pool table of the ClassFile structure has at least one CONSTANT_Dynamic_info or CONSTANT_InvokeDynamic_info entry.
There may be at most one BootstrapMethods attribute in the attributes table of a ClassFile structure.
The BootstrapMethods attribute has the following format:
BootstrapMethods_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 num_bootstrap_methods;
{ u2 bootstrap_method_ref;
u2 num_bootstrap_arguments;
u2 bootstrap_arguments[num_bootstrap_arguments];
} bootstrap_methods[num_bootstrap_methods];
}
The items of the BootstrapMethods_attribute structure are as follows:
-
attribute_name_index
The value of the
attribute_name_indexitem must be a valid index into theconstant_pooltable. Theconstant_poolentry at that index must be aCONSTANT_Utf8_infostructure (§4.4.7) representing the string "BootstrapMethods". -
attribute_length
The value of the
attribute_lengthitem indicates the length of the attribute, excluding the initial six bytes. -
num_bootstrap_methods
The value of the
num_bootstrap_methodsitem determines the number of bootstrap method specifiers in thebootstrap_methodsarray. -
bootstrap_methods[]
Each entry in the
bootstrap_methodstable contains an index to aCONSTANT_MethodHandle_infostructure which specifies a bootstrap method, and a sequence (perhaps empty) of indexes to static arguments for the bootstrap method.Each
bootstrap_methodsentry must contain the following three items:-
bootstrap_method_ref
The value of the
bootstrap_method_refitem must be a valid index into theconstant_pooltable. Theconstant_poolentry at that index must be aCONSTANT_MethodHandle_infostructure (§4.4.8).The method handle will be resolved during resolution of a dynamically-computed constant or call site (§5.4.3.6), and then invoked as if by invocation of
invokeWithArgumentsinjava.lang.invoke.MethodHandle. The method handle must be able to accept the array of arguments described in §5.4.3.6, or resolution will fail. -
num_bootstrap_arguments
The value of the
num_bootstrap_argumentsitem gives the number of items in thebootstrap_argumentsarray. -
bootstrap_arguments[]
Each entry in the
bootstrap_argumentsarray must be a valid index into theconstant_pooltable. Theconstant_poolentry at that index must be loadable (§4.4).
-