Module java.base

Class Executable

All Implemented Interfaces:
AnnotatedElement, GenericDeclaration, Member
Direct Known Subclasses:
Constructor, Method

public abstract class Executable
extends AccessibleObject
implements Member, GenericDeclaration
A shared superclass for the common functionality of Method and Constructor.
Since:
1.8
  • Field Summary

    Fields declared in interface java.lang.reflect.Member

    DECLARED, PUBLIC
  • Method Summary

    Modifier and Type Method Description
    AnnotatedType[] getAnnotatedExceptionTypes()
    Returns an array of AnnotatedType objects that represent the use of types to specify the declared exceptions of the method/constructor represented by this Executable.
    AnnotatedType[] getAnnotatedParameterTypes()
    Returns an array of AnnotatedType objects that represent the use of types to specify formal parameter types of the method/constructor represented by this Executable.
    AnnotatedType getAnnotatedReceiverType()
    Returns an AnnotatedType object that represents the use of a type to specify the receiver type of the method/constructor represented by this Executable object.
    abstract AnnotatedType getAnnotatedReturnType()
    Returns an AnnotatedType object that represents the use of a type to specify the return type of the method/constructor represented by this Executable.
    <T extends Annotation>
    T
    getAnnotation​(Class<T> annotationClass)
    Returns this element's annotation for the specified type if such an annotation is present, else null.
    <T extends Annotation>
    T[]
    getAnnotationsByType​(Class<T> annotationClass)
    Returns annotations that are associated with this element.
    abstract Class<?> getDeclaringClass()
    Returns the Class object representing the class or interface that declares the executable represented by this object.
    abstract Class<?>[] getExceptionTypes()
    Returns an array of Class objects that represent the types of exceptions declared to be thrown by the underlying executable represented by this object.
    Type[] getGenericExceptionTypes()
    Returns an array of Type objects that represent the exceptions declared to be thrown by this executable object.
    Type[] getGenericParameterTypes()
    Returns an array of Type objects that represent the formal parameter types, in declaration order, of the executable represented by this object.
    abstract int getModifiers()
    Returns the Java language modifiers for the executable represented by this object.
    abstract String getName()
    Returns the name of the executable represented by this object.
    abstract Annotation[][] getParameterAnnotations()
    Returns an array of arrays of Annotations that represent the annotations on the formal parameters, in declaration order, of the Executable represented by this object.
    int getParameterCount()
    Returns the number of formal parameters (whether explicitly declared or implicitly declared or neither) for the executable represented by this object.
    Parameter[] getParameters()
    Returns an array of Parameter objects that represent all the parameters to the underlying executable represented by this object.
    abstract Class<?>[] getParameterTypes()
    Returns an array of Class objects that represent the formal parameter types, in declaration order, of the executable represented by this object.
    abstract TypeVariable<?>[] getTypeParameters()
    Returns an array of TypeVariable objects that represent the type variables declared by the generic declaration represented by this GenericDeclaration object, in declaration order.
    boolean isSynthetic()
    Returns true if this executable is a synthetic construct; returns false otherwise.
    boolean isVarArgs()
    Returns true if this executable was declared to take a variable number of arguments; returns false otherwise.
    abstract String toGenericString()
    Returns a string describing this Executable, including any type parameters.