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

# 4.7.31. The `PermittedSubclasses` Attribute

The `PermittedSubclasses` attribute is a variable-length attribute in the `attributes` table of a `ClassFile` structure ([§4.1](4.1.md)). The `PermittedSubclasses` attribute records the classes and interfaces that are authorized to directly extend or implement the current class or interface ([§5.3.5](5.3.5.md)).

The Java programming language uses the modifier `sealed` to indicate a class or interface that limits its direct subclasses or direct subinterfaces. One might suppose that this modifier would correspond to an `ACC_SEALED` flag in a `class` file, since the related modifier `final` corresponds to the `ACC_FINAL` flag. In fact, a `sealed` class or interface is indicated in a `class` file by the presence of the `PermittedSubclasses` attribute.

There may be at most one `PermittedSubclasses` attribute in the `attributes` table of a `ClassFile` structure whose `access_flags` item does not have the `ACC_FINAL` flag set.

There must be no `PermittedSubclasses` attribute in the `attributes` table of a `ClassFile` structure whose `access_flags` item has the `ACC_FINAL` flag set.

`sealed` is distinct from `final`: a `sealed` class has a list of authorized subclasses, which a `final` class has no subclasses. Thus, a `ClassFile` structure may have a `PermittedSubclasses` attribute, or have its `ACC_FINAL` flag set, but not both.

The `PermittedSubclasses` attribute has the following format:

```
PermittedSubclasses_attribute {
    u2 attribute_name_index;
    u4 attribute_length;
    u2 number_of_classes;
    u2 classes[number_of_classes];
}
```

The items of the `PermittedSubclasses_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 "`PermittedSubclasses`".

- **attribute_length**

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

- **number_of_classes**

  The value of the `number_of_classes` item indicates the number of entries in the `classes` array.

- **classes[]**

  Each value in the `classes` array 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 authorized to directly extend or implement the current class or interface.

  The `classes` array is consulted when a class or interface is created that attempts to directly extend or implement the current class or interface ([§5.3.5](5.3.5.md)). Array items that represent classes or interfaces which do not attempt to directly extend or implement the current class or interface are ignored.
