ExecutableElement (Java Platform SE 8 ) (original) (raw)
- All Superinterfaces:
AnnotatedConstruct, Element, Parameterizable
public interface ExecutableElement
extends Element, Parameterizable
Represents a method, constructor, or initializer (static or instance) of a class or interface, including annotation type elements.
Since:
1.6
See Also:
ExecutableType
Method Summary
All Methods Instance Methods Abstract Methods
Modifier and Type Method Description AnnotationValue getDefaultValue() Returns the default value if this executable is an annotation type element. List<? extends VariableElement> getParameters() Returns the formal parameters of this executable. TypeMirror getReceiverType() Returns the receiver type of this executable, or NoType with kind NONE if the executable has no receiver type. TypeMirror getReturnType() Returns the return type of this executable. Name getSimpleName() Returns the simple name of a constructor, method, or initializer. List<? extends TypeMirror> getThrownTypes() Returns the exceptions and other throwables listed in this method or constructor's throws clause in declaration order. List<? extends TypeParameterElement> 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 inherited from interface javax.lang.model.element.[Element](../../../../javax/lang/model/element/Element.html "interface in javax.lang.model.element") `[accept](../../../../javax/lang/model/element/Element.html#accept-javax.lang.model.element.ElementVisitor-P-), [asType](../../../../javax/lang/model/element/Element.html#asType--), [equals](../../../../javax/lang/model/element/Element.html#equals-java.lang.Object-), [getAnnotation](../../../../javax/lang/model/element/Element.html#getAnnotation-java.lang.Class-), [getAnnotationMirrors](../../../../javax/lang/model/element/Element.html#getAnnotationMirrors--), [getEnclosedElements](../../../../javax/lang/model/element/Element.html#getEnclosedElements--), [getEnclosingElement](../../../../javax/lang/model/element/Element.html#getEnclosingElement--), [getKind](../../../../javax/lang/model/element/Element.html#getKind--), [getModifiers](../../../../javax/lang/model/element/Element.html#getModifiers--), [hashCode](../../../../javax/lang/model/element/Element.html#hashCode--)` * ### Methods inherited from interface javax.lang.model.[AnnotatedConstruct](../../../../javax/lang/model/AnnotatedConstruct.html "interface in javax.lang.model") `[getAnnotationsByType](../../../../javax/lang/model/AnnotatedConstruct.html#getAnnotationsByType-java.lang.Class-)`
Method Detail
* #### getTypeParameters [List](../../../../java/util/List.html "interface in java.util")<? extends [TypeParameterElement](../../../../javax/lang/model/element/TypeParameterElement.html "interface in javax.lang.model.element")> getTypeParameters() Returns the formal type parameters of this executable in declaration order. Specified by: `[getTypeParameters](../../../../javax/lang/model/element/Parameterizable.html#getTypeParameters--)` in interface `[Parameterizable](../../../../javax/lang/model/element/Parameterizable.html "interface in javax.lang.model.element")` Returns: the formal type parameters, or an empty list if there are none * #### getReturnType [TypeMirror](../../../../javax/lang/model/type/TypeMirror.html "interface in javax.lang.model.type") getReturnType() Returns the return type of this executable. Returns a [NoType](../../../../javax/lang/model/type/NoType.html "interface in javax.lang.model.type") with kind [VOID](../../../../javax/lang/model/type/TypeKind.html#VOID) if this executable is not a method, or is a method that does not return a value. Returns: the return type of this executable * #### getParameters [List](../../../../java/util/List.html "interface in java.util")<? extends [VariableElement](../../../../javax/lang/model/element/VariableElement.html "interface in javax.lang.model.element")> getParameters() Returns the formal parameters of this executable. They are returned in declaration order. Returns: the formal parameters, or an empty list if there are none * #### getReceiverType [TypeMirror](../../../../javax/lang/model/type/TypeMirror.html "interface in javax.lang.model.type") getReceiverType() Returns the receiver type of this executable, or [NoType](../../../../javax/lang/model/type/NoType.html "interface in javax.lang.model.type") with kind [NONE](../../../../javax/lang/model/type/TypeKind.html#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](../../../../javax/lang/model/element/Element.html#getEnclosingElement--). 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. Returns: the receiver type of this executable Since: 1.8 * #### isVarArgs boolean isVarArgs() Returns `true` if this method or constructor accepts a variable number of arguments and returns `false` otherwise. Returns: `true` if this method or constructor accepts a variable number of arguments and `false` otherwise * #### isDefault boolean isDefault() Returns `true` if this method is a default method and returns `false` otherwise. Returns: `true` if this method is a default method and`false` otherwise Since: 1.8 * #### getThrownTypes [List](../../../../java/util/List.html "interface in java.util")<? extends [TypeMirror](../../../../javax/lang/model/type/TypeMirror.html "interface in javax.lang.model.type")> getThrownTypes() Returns the exceptions and other throwables listed in this method or constructor's `throws` clause in declaration order. Returns: the exceptions and other throwables listed in the`throws` clause, or an empty list if there are none * #### getDefaultValue [AnnotationValue](../../../../javax/lang/model/element/AnnotationValue.html "interface in javax.lang.model.element") getDefaultValue() Returns the default value if this executable is an annotation type element. Returns `null` if this method is not an annotation type element, or if it is an annotation type element with no default value. Returns: the default value, or `null` if none * #### getSimpleName [Name](../../../../javax/lang/model/element/Name.html "interface in javax.lang.model.element") getSimpleName() Returns the simple name of a constructor, method, or initializer. For a constructor, the name `"<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: `[getSimpleName](../../../../javax/lang/model/element/Element.html#getSimpleName--)` in interface `[Element](../../../../javax/lang/model/element/Element.html "interface in javax.lang.model.element")` Returns: the simple name of a constructor, method, or initializer See Also: [PackageElement.getSimpleName()](../../../../javax/lang/model/element/PackageElement.html#getSimpleName--), [getSimpleName()](../../../../javax/lang/model/element/ExecutableElement.html#getSimpleName--), [TypeElement.getSimpleName()](../../../../javax/lang/model/element/TypeElement.html#getSimpleName--), [VariableElement.getSimpleName()](../../../../javax/lang/model/element/VariableElement.html#getSimpleName--)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.