---
spec: JVMS
title: "The Java Virtual Machine Specification"
edition: "Java SE 15 Edition"
java_version: 15
chapter: "Chapter 4. The class File Format"
section: "4.7.23"
heading: "4.7.23. The BootstrapMethods Attribute"
parent: "4.7. Attributes"
source: https://docs.oracle.com/javase/specs/jvms/se15/html/jvms-4.html#jvms-4.7.23
id: "4.7.23"
url: https://jvm.obfuscated.software/jvms/se15/4.7.23.html
raw: https://jvm.obfuscated.software/jvms/se15/4.7.23.md
---

# 4.7.23. The `BootstrapMethods` Attribute

The `BootstrapMethods` attribute is a variable-length attribute in the `attributes` table of a `ClassFile` structure ([§4.1](4.1.md)). The `BootstrapMethods` attribute records bootstrap methods used to produce dynamically-computed constants and dynamically-computed call sites ([§4.4.10](4.4.10.md)).

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_index` item must be a valid index into the `constant_pool` table. The `constant_pool` entry at that index must be a `CONSTANT_Utf8_info` structure ([§4.4.7](4.4.7.md)) representing the string "`BootstrapMethods`".

- **attribute_length**

  The value of the `attribute_length` item indicates the length of the attribute, excluding the initial six bytes.

- **num_bootstrap_methods**

  The value of the `num_bootstrap_methods` item determines the number of bootstrap method specifiers in the `bootstrap_methods` array.

- **bootstrap_methods[]**

  Each entry in the `bootstrap_methods` table contains an index to a `CONSTANT_MethodHandle_info` structure which specifies a bootstrap method, and a sequence (perhaps empty) of indexes to *static arguments* for the bootstrap method.

  Each `bootstrap_methods` entry must contain the following three items:

  - **bootstrap_method_ref**

    The value of the `bootstrap_method_ref` item must be a valid index into the `constant_pool` table. The `constant_pool` entry at that index must be a `CONSTANT_MethodHandle_info` structure ([§4.4.8](4.4.8.md)).

    The method handle will be resolved during resolution of a dynamically-computed constant or call site ([§5.4.3.6](5.4.3.6.md)), and then invoked as if by invocation of `invokeWithArguments` in `java.lang.invoke.MethodHandle`. The method handle must be able to accept the array of arguments described in [§5.4.3.6](5.4.3.6.md), or resolution will fail.

  - **num_bootstrap_arguments**

    The value of the `num_bootstrap_arguments` item gives the number of items in the `bootstrap_arguments` array.

  - **bootstrap_arguments[]**

    Each entry in the `bootstrap_arguments` array must be a valid index into the `constant_pool` table. The `constant_pool` entry at that index must be loadable ([§4.4](4.4.md)).
