Deprecated attribute
Marks a deprecated declaration.
- Appears on
- class, field, method
- Since
- class file 45.0 (Java 1.1)
- javac writes it
- for @Deprecated declarations
- 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: "Deprecated" |
u4 | attribute_length | bytes after this field |
What it is for
Marks a deprecated declaration. It has no contents. javac writes it alongside the @Deprecated annotation, which is what tools now use.
How common it is
JDK 25.0.5's java.base has 315 Deprecated attributes, in 163 of its 7,391 classes (204 on methods, 48 on classs, 63 on fields).
A real one, byte by byte
From Annotations.class (compiled by javac 25), on method old:
| Offset | Bytes | Field | Value |
|---|---|---|---|
| 1364 | 6 bytes | Deprecated | |
| 1364 | 00 2d | attribute_name_index | #45 |
| 1366 | 00 00 00 00 | attribute_length | 0 |
Specification: JVMS §4.7, The Deprecated Attribute (Java SE 25).