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

# 4.7.8. The `Synthetic` Attribute

The `Synthetic` attribute is a fixed-length attribute in the `attributes` table of a `ClassFile`, `field_info`, or `method_info` structure ([§4.1](4.1.md), [§4.5](4.5.md), [§4.6](4.6.md)). A class member that does not appear in the source code must be marked using a `Synthetic` attribute, or else it must have its `ACC_SYNTHETIC` flag set. The only exceptions to this requirement are compiler-generated members which are not considered implementation artifacts, namely:

- an instance initialization method representing a default constructor of the Java programming language ([§2.9.1](2.9.1.md))
- a class or interface initialization method ([§2.9.2](2.9.2.md))
- the implicitly declared members of enum and record classes (JLS §8.9.3, JLS §8.10.3)

The `Synthetic` attribute was introduced in JDK 1.1 to support nested classes and interfaces.

It is a limitation of the `class` file format that only formal parameters and modules can be flagged as `ACC_MANDATED` ([§4.7.24](4.7.24.md), [§4.7.25](4.7.25.md)) to indicate that, despite being compiler-generated, they are not considered implementation artifacts. There is no way to flag other compiler-generated constructs so that they too are not considered implementation artifacts (JLS §13.1). This limitation means that reflective APIs of the Java SE Platform may not accurately indicate the "mandated" status of such constructs.

The `Synthetic` attribute has the following format:

```
Synthetic_attribute {
    u2 attribute_name_index;
    u4 attribute_length;
}
```

The items of the `Synthetic_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 "`Synthetic`".

- **attribute_length**

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