Exceptions attribute

The checked exceptions a method declares.

Appears on
method
Since
class file 45.0 (Java 1.0)
javac writes it
for methods with a throws clause
Needed by the JVM
no: it is for the class libraries (reflection), compilers or tools

Layout

TypeFieldWhat it holds
u2attribute_name_indexa Utf8: "Exceptions"
u4attribute_lengthbytes after this field
u2number_of_exceptions
u2[…]exception_index_tableClass entries

What it is for

The checked exceptions a method declares. The JVM ignores it: checked exceptions are purely a compiler rule, which is how other JVM languages, and sneaky-throw tricks, throw checked exceptions undeclared. Reflection reads it for getExceptionTypes().

How common it is

JDK 25.0.5's java.base has 8,427 Exceptions attributes, in 1,951 of its 7,391 classes (8,427 on methods).

A real one, byte by byte

From TryResources.class (compiled by javac 25), on method firstLine:

OffsetBytesFieldValue
88310 bytesExceptions
88300 2eattribute_name_index#46
88500 00 00 04attribute_length4
88900 01number_of_exceptions1
89100 2fexception_index#47

Open in the viewer

Specification: JVMS §4.7, The Exceptions Attribute (Java SE 25).