Synthetic attribute
Marks a member the compiler generated that does not appear in the source.
- Appears on
- class, field, method
- Since
- class file 45.0 (Java 1.1)
- javac writes it
- not by modern javac, which sets the ACC_SYNTHETIC flag instead
- Needed by the JVM
- no: it is for the class libraries (reflection), compilers or tools
Layout
Only the common header: the attribute has no contents of its own.
| Type | Field | What it holds |
|---|---|---|
u2 | attribute_name_index | a Utf8: "Synthetic" |
u4 | attribute_length | bytes after this field |
What it is for
Marks a member the compiler generated that does not appear in the source. Since class file version 49 the ACC_SYNTHETIC flag says the same thing, and javac uses the flag.
How common it is
None of the 7,391 classes in JDK 25.0.5's java.base has one.
Specification: JVMS §4.7, The Synthetic Attribute (Java SE 25).