- All Superinterfaces:
Attribute<EnclosingMethodAttribute>,ClassElement,ClassFileElement,WritableElement<EnclosingMethodAttribute>
- All Known Implementing Classes:
BoundAttribute.BoundEnclosingMethodAttribute,UnboundAttribute.UnboundEnclosingMethodAttribute
public sealed interface EnclosingMethodAttribute
extends Attribute<EnclosingMethodAttribute>, ClassElement
permits BoundAttribute.BoundEnclosingMethodAttribute, UnboundAttribute.UnboundEnclosingMethodAttribute
Models the
EnclosingMethod attribute , 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:
- 22
-
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 EnclosingMethodAttributeReturns anEnclosingMethodattribute.static EnclosingMethodAttributeof(ClassEntry className, Optional<NameAndTypeEntry> method) Returns anEnclosingMethodattribute.Methods inherited from interface org.glavo.classfile.Attribute
attributeMapper, attributeNameMethods inherited from interface org.glavo.classfile.WritableElement
writeTo
-
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
Returns the name 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
-
enclosingMethodType
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
-
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 anEnclosingMethodattribute.- Parameters:
className- the class namemethod- the name and type of the enclosing method oremptyif the class is not immediately enclosed by a method or constructor- Returns:
- an
EnclosingMethodattribute
-
of
static EnclosingMethodAttribute of(ClassDesc className, Optional<String> methodName, Optional<MethodTypeDesc> methodType) Returns anEnclosingMethodattribute.- Parameters:
className- the class namemethodName- the name of the enclosing method oremptyif the class is not immediately enclosed by a method or constructormethodType- the type of the enclosing method oremptyif the class is not immediately enclosed by a method or constructor- Returns:
- an
EnclosingMethodattribute - Throws:
IllegalArgumentException- ifclassNamerepresents a primitive type
-