---
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.28"
heading: "4.7.28. The NestHost Attribute"
parent: "4.7. Attributes"
source: https://docs.oracle.com/javase/specs/jvms/se15/html/jvms-4.html#jvms-4.7.28
id: "4.7.28"
url: https://jvm.obfuscated.software/jvms/se15/4.7.28.html
raw: https://jvm.obfuscated.software/jvms/se15/4.7.28.md
---

# 4.7.28. The `NestHost` Attribute

The `NestHost` attribute is a fixed-length attribute in the `attributes` table of a `ClassFile` structure. The `NestHost` attribute records the nest host of the nest to which the current class or interface claims to belong ([§5.4.4](5.4.4.md)).

There may be at most one `NestHost` attribute in the `attributes` table of a `ClassFile` structure.

The `NestHost` attribute has the following format:

```
NestHost_attribute {
    u2 attribute_name_index;
    u4 attribute_length;
    u2 host_class_index;
}
```

The items of the `NestHost_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 "`NestHost`".

- **attribute_length**

  The value of the `attribute_length` item must be two.

- **host_class_index**

  The value of the `host_class_index` item must be a valid index into the `constant_pool` table. The `constant_pool` entry at that index must be a `CONSTANT_Class_info` structure ([§4.4.1](4.4.1.md)) representing a class or interface which is the nest host for the current class or interface.

  If the nest host cannot be loaded, or is not in the same run-time package as the current class or interface, or does not authorize nest membership for the current class or interface, then an error may occur during access control ([§5.4.4](5.4.4.md)).
