APIdia Launch Partner
Top Description Methods
java.lang.classfile.attribute

public sealed Interface ExceptionsAttribute

extends Attribute<ExceptionsAttribute>, MethodElement
permits BoundExceptionsAttribute, UnboundExceptionsAttribute
Known Direct Implementers
jdk.internal.classfile.impl.BoundAttribute.BoundExceptionsAttribute, jdk.internal.classfile.impl.UnboundAttribute.UnboundExceptionsAttribute
Imports
java.lang.classfile.Attribute, .AttributeMapper, .AttributeMapper.AttributeStability, .Attributes, .ClassFile, .MethodElement, java.lang.classfile.constantpool.ClassEntry, java.lang.constant.ClassDesc, java.lang.reflect.Executable, java.util.Arrays, .List, jdk.internal.classfile.impl.BoundAttribute, .UnboundAttribute, .Util

Models the Exceptions attribute (JVMS 4.7.5), which records the exceptions declared to be thrown by this method.

This attribute only appears on methods, and does not permit multiple instances in a method. It has a data dependency on the constant pool.

The attribute was introduced in the Java Platform version 1.0.2, major version 45.

API Note

Generic exceptions types thrown by a method and potentially annotated use of those types are defined by SignatureAttribute and RuntimeVisibleTypeAnnotationsAttribute respectively, which requires this attribute to be present.

Since
24
Java Virtual Machine Specification
4.7.5 The Exceptions Attribute
See Also
Attributes#exceptions()

Method Summary

Modifier and TypeMethod and Description
public List<ClassEntry>

Returns:

the exceptions declared to be thrown by this method
exceptions
()

Returns the exceptions declared to be thrown by this method.

public static ExceptionsAttribute

Returns:

an Exceptions attribute
of
(List<ClassEntry>
the exceptions that may be thrown from this method
exceptions
)

Returns an Exceptions attribute.

public static ExceptionsAttribute

Returns:

an Exceptions attribute
of
(ClassEntry...
the exceptions that may be thrown from this method
exceptions
)

Returns an Exceptions attribute.

public static ExceptionsAttribute

Returns:

an Exceptions attribute
ofSymbols
(List<ClassDesc>
the exceptions that may be thrown from this method
exceptions
)

Returns an Exceptions attribute.

public static ExceptionsAttribute

Returns:

an Exceptions attribute
ofSymbols
(ClassDesc...
the exceptions that may be thrown from this method
exceptions
)

Returns an Exceptions attribute.

Inherited from java.lang.classfile.Attribute:
attributeMapperattributeName

Method Detail

exceptionsback to summary
public List<ClassEntry> exceptions()

Returns the exceptions declared to be thrown by this method.

Returns:List<ClassEntry>

the exceptions declared to be thrown by this method

See Also
Executable#getExceptionTypes()
ofback to summary
public static ExceptionsAttribute of(List<ClassEntry> exceptions)

Returns an Exceptions attribute.

Parameters
exceptions:List<ClassEntry>

the exceptions that may be thrown from this method

Returns:ExceptionsAttribute

an Exceptions attribute

Exceptions
IllegalArgumentException:
if the number of exceptions exceeds the limit of u2
ofback to summary
public static ExceptionsAttribute of(ClassEntry... exceptions)

Returns an Exceptions attribute.

Parameters
exceptions:ClassEntry[]

the exceptions that may be thrown from this method

Returns:ExceptionsAttribute

an Exceptions attribute

Exceptions
IllegalArgumentException:
if the number of exceptions exceeds the limit of u2
ofSymbolsback to summary
public static ExceptionsAttribute ofSymbols(List<ClassDesc> exceptions)

Returns an Exceptions attribute.

Parameters
exceptions:List<ClassDesc>

the exceptions that may be thrown from this method

Returns:ExceptionsAttribute

an Exceptions attribute

Exceptions
IllegalArgumentException:
if the number of exceptions exceeds the limit of u2
ofSymbolsback to summary
public static ExceptionsAttribute ofSymbols(ClassDesc... exceptions)

Returns an Exceptions attribute.

Parameters
exceptions:ClassDesc[]

the exceptions that may be thrown from this method

Returns:ExceptionsAttribute

an Exceptions attribute

Exceptions
IllegalArgumentException:
if the number of exceptions exceeds the limit of u2