Interface ExecutableElement
- All Superinterfaces:
AnnotatedConstruct, Element, Parameterizable
public interface ExecutableElement extends Element, Parameterizable
throws clause, among other restrictions; see JLS 9.6.1 for details.- Since:
- 1.6
- See Also:
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
TypeMirror |
asType() |
Returns the executable type defined by this executable element. |
AnnotationValue |
getDefaultValue() |
Returns the default value if this executable is an annotation interface element. |
Element |
getEnclosingElement() |
Returns the class or interface defining the executable. |
List |
getParameters() |
Returns the formal parameters of this executable. |
TypeMirror |
getReceiverType() |
|
TypeMirror |
getReturnType() |
Returns the return type of this executable. |
Name |
getSimpleName() |
Returns the simple name of a constructor, method, or initializer. |
List |
getThrownTypes() |
Returns the exceptions and other throwables listed in this method or constructor's throws clause in declaration order. |
List |
getTypeParameters() |
Returns the formal type parameters of this executable in declaration order. |
boolean |
isDefault() |
Returns true if this method is a default method and returns false otherwise. |
boolean |
isVarArgs() |
Returns true if this method or constructor accepts a variable number of arguments and returns false otherwise. |
Methods declared in interface Element
accept, equals, getAnnotation, getAnnotationMirrors, getAnnotationsByType, getEnclosedElements, getKind, getModifiers, hashCode
Method Details
asType
TypeMirror asType()
- Specified by:
-
asTypein interfaceElement - Returns:
- the executable type defined by this executable element
- See Also:
getTypeParameters
List<? extends TypeParameterElement> getTypeParameters()
- Specified by:
-
getTypeParametersin interfaceParameterizable - Returns:
- the formal type parameters, or an empty list if there are none
getReturnType
getParameters
List<? extends VariableElement> getParameters()
- Returns:
- the formal parameters, or an empty list if there are none
getReceiverType
TypeMirror getReceiverType()
NoType with kind NONE if the executable has no receiver type. An executable which is an instance method, or a constructor of an inner class, has a receiver type derived from the declaring type. An executable which is a static method, or a constructor of a non-inner class, or an initializer (static or instance), has no receiver type. The receiver parameter is a syntactic device added to the language for the purpose of hosting annotations. Even when source code is used as the basis for creating an executable, if a receiver parameter is not present in the source code, an implementation may elect to return a
NoType object even in cases where a receiver type is nominally defined on the executable in question, such as an instance method. When a receiver parameter is present and hosting annotations, a suitably annotated receiver type is returned.
- Returns:
- the receiver type of this executable
- See Java Language Specification:
- 8.4 Method Declarations
8.4.1 Formal Parameters
8.8 Constructor Declarations
- Since:
- 1.8
isVarArgs
boolean isVarArgs()
true if this method or constructor accepts a variable number of arguments and returns false otherwise.- Returns:
-
trueif this method or constructor accepts a variable number of arguments and returnsfalseotherwise
isDefault
boolean isDefault()
true if this method is a default method and returns false otherwise.- Returns:
-
trueif this method is a default method and returnsfalseotherwise - Since:
- 1.8
getThrownTypes
List<? extends TypeMirror> getThrownTypes()
throws clause in declaration order.- Returns:
- the exceptions and other throwables listed in the
throwsclause, or an empty list if there are none
getDefaultValue
AnnotationValue getDefaultValue()
null if this method is not an annotation interface element, or if it is an annotation interface element with no default value.- Returns:
- the default value, or
nullif none
getEnclosingElement
Element getEnclosingElement()
- Specified by:
-
getEnclosingElementin interfaceElement - Returns:
- the class or interface defining the executable
- See Also:
getSimpleName
Name getSimpleName()
"<init>" is returned, for a static initializer, the name "<clinit>" is returned, and for an anonymous class or instance initializer, an empty name is returned.- Specified by:
-
getSimpleNamein interfaceElement - Returns:
- the simple name of a constructor, method, or initializer
- See Also:
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/java.compiler/javax/lang/model/element/ExecutableElement.html