Interface EnclosingMethodAttribute
- All Superinterfaces:
Attribute<EnclosingMethodAttribute>, ClassElement, ClassFileElement
public sealed interface EnclosingMethodAttribute
extends Attribute<EnclosingMethodAttribute>, ClassElement
Models the
EnclosingMethod
attribute (JVMS 4.7.7), which can appear
on classes, and indicates that the class is a local or anonymous class.
Delivered as a ClassElement
when traversing the elements of a ClassModel
.
The attribute does not permit multiple instances in a given location. Subsequent occurrence of the attribute takes precedence during the attributed element build or transformation.
The attribute was introduced in the Java SE Platform version 5.0.
- Since:
- 24
-
Method Summary
Modifier and TypeMethodDescriptionReturns the innermost class that encloses the declaration of the current class.Returns the name and type of the enclosing method, if the class is immediately enclosed by a method or constructor.Returns the name of the enclosing method, if the class is immediately enclosed by a method or constructor.Returns the type of the enclosing method, if the class is immediately enclosed by a method or constructor.default Optional
<MethodTypeDesc> Returns the type of the enclosing method, if the class is immediately enclosed by a method or constructor.static EnclosingMethodAttribute
of
(ClassEntry className, Optional<NameAndTypeEntry> method) Returns anEnclosingMethod
attribute.static EnclosingMethodAttribute
Returns anEnclosingMethod
attribute.Methods declared in interface Attribute
attributeMapper, attributeName
-
Method Details
-
enclosingClass
ClassEntry enclosingClass()Returns the innermost class that encloses the declaration of the current class.- Returns:
- the innermost class that encloses the declaration of the current class
-
enclosingMethod
Optional<NameAndTypeEntry> enclosingMethod()Returns the name and type of the enclosing method, if the class is immediately enclosed by a method or constructor.- Returns:
- the name and type of the enclosing method, if the class is immediately enclosed by a method or constructor
-
enclosingMethodName
-
enclosingMethodType
-
enclosingMethodTypeSymbol
Returns the type of the enclosing method, if the class is immediately enclosed by a method or constructor.- Returns:
- the type of the enclosing method, if the class is immediately enclosed by a method or constructor
-
of
Returns anEnclosingMethod
attribute.- Parameters:
className
- the class namemethod
- the name and type of the enclosing method orempty
if the class is not immediately enclosed by a method or constructor- Returns:
- an
EnclosingMethod
attribute
-
of
static EnclosingMethodAttribute of(ClassDesc className, Optional<String> methodName, Optional<MethodTypeDesc> methodType) Returns anEnclosingMethod
attribute.- Parameters:
className
- the class namemethodName
- the name of the enclosing method orempty
if the class is not immediately enclosed by a method or constructormethodType
- the type of the enclosing method orempty
if the class is not immediately enclosed by a method or constructor- Returns:
- an
EnclosingMethod
attribute - Throws:
IllegalArgumentException
- ifclassName
represents a primitive type
-