public final class Method extends AccessibleObject implements GenericDeclaration, Member
Method
provides information about, and access to, a single method
on a class or interface. The reflected method may be a class method
or an instance method (including an abstract method).
A Method
permits widening conversions to occur when matching the
actual parameters to invoke with the underlying method's formal
parameters, but it throws an IllegalArgumentException
if a
narrowing conversion would occur.
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Compares this
Method against the specified object. |
<T extends Annotation> |
getAnnotation(Class<T> annotationClass)
Returns this element's annotation for the specified type if
such an annotation is present, else null.
|
Annotation[] |
getDeclaredAnnotations()
Returns all annotations that are directly present on this
element.
|
Class<?> |
getDeclaringClass()
Returns the
Class object representing the class or interface
that declares the method represented by this Method object. |
Object |
getDefaultValue()
Returns the default value for the annotation member represented by
this
Method instance. |
Class<?>[] |
getExceptionTypes()
Returns an array of
Class objects that represent
the types of the exceptions declared to be thrown
by the underlying method
represented by this Method object. |
Type[] |
getGenericExceptionTypes()
Returns an array of
Type objects that represent the
exceptions declared to be thrown by this Method object. |
Type[] |
getGenericParameterTypes()
Returns an array of
Type objects that represent the formal
parameter types, in declaration order, of the method represented by
this Method object. |
Type |
getGenericReturnType()
Returns a
Type object that represents the formal return
type of the method represented by this Method object. |
int |
getModifiers()
Returns the Java language modifiers for the method represented
by this
Method object, as an integer. |
String |
getName()
Returns the name of the method represented by this
Method
object, as a String . |
Annotation[][] |
getParameterAnnotations()
Returns an array of arrays that represent the annotations on the formal
parameters, in declaration order, of the method represented by
this
Method object. |
Class<?>[] |
getParameterTypes()
Returns an array of
Class objects that represent the formal
parameter types, in declaration order, of the method
represented by this Method object. |
Class<?> |
getReturnType()
Returns a
Class object that represents the formal return type
of the method represented by this Method object. |
TypeVariable<Method>[] |
|