EnclosingMethod attribute
(JVMS 4.7.7), which indicates that this class is a local or
anonymous class, and indicates the enclosing method or constructor of this
class if this class is enclosed in exactly one method or constructor.
This attribute only appears on classes, and does not permit multiple instances in a class. It has a data dependency on the constant pool.
The attribute was introduced in the Java SE Platform version 5.0, major version 49.
EnclosingMethod Attribute
Attributes#enclosingMethod()
| Modifier and Type | Method and Description |
|---|---|
| public ClassEntry | Returns: the class that encloses the declaration of the current classReturns the class that encloses the declaration of the current class. |
| public Optional | Returns: the name and type of the enclosing method, if the class is immediately enclosed by exactly one method or constructorReturns the name and type of the enclosing method, if the class is immediately enclosed by exactly one method or constructor. |
| public default Optional | Returns: the name of the enclosing method, if the class is immediately enclosed by exactly one method or constructorReturns the name of the enclosing method, if the class is immediately enclosed by exactly one method or constructor. |
| public default Optional | Returns: the name of the enclosing method, if the class is immediately enclosed by exactly one method or constructorReturns the name of the enclosing method, if the class is immediately enclosed by exactly one method or constructor. |
| public default Optional | Returns: the name of the enclosing method, if the class is immediately enclosed by exactly one method or constructorReturns the name of the enclosing method, if the class is immediately enclosed by exactly one method or constructor. |
| public static EnclosingMethodAttribute | Returns: anEnclosingMethod attributethe class name className, Optional<NameAndTypeEntry> the name and type of the enclosing method or method)Optional.empty() if
the class is not immediately enclosed by exactly one method or constructorReturns an |
| public static EnclosingMethodAttribute | Returns: anEnclosingMethod attributethe class name className, Optional<String> the name of the enclosing method or methodName, Optional<MethodTypeDesc> Optional.empty() if
the class is not immediately enclosed by exactly one method or constructorthe type of the enclosing method or methodType)Optional.empty() if
the class is not immediately enclosed by exactly one method or constructorReturns an |
| enclosingClass | back to summary |
|---|---|
| public ClassEntry enclosingClass() Returns the class that encloses the declaration of the current
class. If the
| |
| enclosingMethod | back to summary |
|---|---|
| public Optional Returns the name and type of the enclosing method, if the class is immediately enclosed by exactly one method or constructor. This may be empty if the anonymous or local class appears in a field initializer (JLS 8.3.2), an instance initializer (JLS 8.6), or a static initializer (JLS 8.7). As a result, this never describes a class initialization method <clinit>.
| |
| enclosingMethodName | back to summary |
|---|---|
| public default Optional Returns the name of the enclosing method, if the class is immediately enclosed by exactly one method or constructor.
| |
| enclosingMethodType | back to summary |
|---|---|
| public default Optional Returns the name of the enclosing method, if the class is immediately enclosed by exactly one method or constructor.
| |
| enclosingMethodTypeSymbol | back to summary |
|---|---|
| public default Optional Returns the name of the enclosing method, if the class is immediately enclosed by exactly one method or constructor.
| |
| of | back to summary |
|---|---|
| public static EnclosingMethodAttribute of(ClassEntry className, Optional<NameAndTypeEntry> method) Returns an
| |
| of | back to summary |
|---|---|
| public static EnclosingMethodAttribute of(ClassDesc className, Optional<String> methodName, Optional<MethodTypeDesc> methodType) Returns an
| |