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.
Member, java.lang.Class , java.lang.Class#getMethods() , java.lang.Class#getMethod(String, Class[]) , java.lang.Class#getDeclaredMethods() , java.lang.Class#getDeclaredMethod(String, Class[])
| Modifier and Type | Field and Description |
|---|---|
| private final byte[] | |
| private final byte[] | |
| private byte | |
| private final Class | |
| private final Class | |
| private transient volatile MethodRepository | |
| private int | |
| private MethodAccessor | |
| private final int | |
| private final String | |
| private final byte[] | |
| private final Class | |
| private final Class | |
| private Method | root
Methods are mutable due to |
| private final transient String | |
| private final int |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private MethodAccessor | |
| pack-priv void | |
| pack-priv void | checkCanSetAccessible(Class<?> caller)
Overrides java. If the given AccessibleObject is a |
| pack-priv Method | copy()
Package-private routine (exposed to java.lang.Class via ReflectAccess) which returns a copy of this Method. |
| public boolean | equals(Object obj)
Overrides java. Compares this |
| public AnnotatedType | getAnnotatedReturnType()
Implements abstract java. Returns an |
| public <T extends Annotation> T | getAnnotation(Class<T> annotationClass)
Overrides java. Implements java. Returns this element's annotation for the specified type if such an annotation is present, else null. |
| pack-priv byte[] | getAnnotationBytes()
Implements abstract java. Accessor method to allow code sharing |
| public Annotation[] | getDeclaredAnnotations()
Overrides java. Implements java. Returns annotations that are directly present on this element. |
| public Class | getDeclaringClass()
Implements abstract java. Implements java. Returns the |
| public Object | Returns: the default value for the annotation member represented by thisMethod instance.Returns the default value for the annotation member represented by
this |
| public Class | getExceptionTypes()
Implements abstract java. Returns an array of |
| private GenericsFactory | |
| public Type[] | getGenericExceptionTypes()
Overrides java. Returns an array of |
| pack-priv MethodRepository | |
| public Type[] | getGenericParameterTypes()
Overrides java. Returns an array of |
| public Type | Returns: aType object that represents the formal return
type of the underlying methodReturns a |
| private String | |
| pack-priv MethodAccessor | |
| public int | getModifiers()
Implements abstract java. Implements java. Returns the Java language modifiers for the executable represented by this object. |
| public String | getName()
Implements abstract java. Implements java. Returns the name of the method represented by this |
| public Annotation[][] | getParameterAnnotations()
Implements abstract java. Returns an array of arrays of |
| public int | getParameterCount()
Implements abstract java. Returns the number of formal parameters (whether explicitly declared or implicitly declared or neither) for the executable represented by this object. |
| public Class | getParameterTypes()
Implements abstract java. Returns an array of |
| public Class | Returns: the return type for the method this object representsReturns a |
| pack-priv Method | getRoot()
Overrides java. Returns the root AccessibleObject; or null if this object is the root. |
| pack-priv Class | |
| pack-priv Class | |
| public TypeVariable | getTypeParameters()
Implements abstract java. Implements java. Returns an array of |
| pack-priv boolean | handleParameterNumberMismatch(int resultLength, Class<?>[] parameterTypes)
Implements abstract java.
|
| pack-priv boolean | hasGenericInformation()
Implements abstract java. Does the Executable have generic information. |
| public int | |
| public Object | Returns: the result of dispatching the method represented by this object onobj with parameters
argsthe object the underlying method is invoked from obj, Object... the arguments used for the method call args)Invokes the underlying method represented by this |
| private Object | |
| public boolean | Returns: true if this method is a bridge
method; returns false otherwiseReturns |
| private boolean | |
| public boolean | Returns: true if and only if this method is a default method as defined by the Java Language Specification.Returns |
| public boolean | isSynthetic()
Overrides java. Implements java. Returns |
| public boolean | isVarArgs()
Overrides java. Returns |
| public void | setAccessible(boolean flag)
Overrides java. Set the |
| pack-priv void | |
| pack-priv void | specificToGenericStringHeader(StringBuilder sb)
Implements abstract java. Generate toGenericString header information specific to a method or constructor. |
| pack-priv void | specificToStringHeader(StringBuilder sb)
Implements abstract java. Generate toString header information specific to a method or constructor. |
| public String | Returns: a string describing thisMethod,
include type parametersOverrides java. Returns a string describing this |
| pack-priv String | |
| pack-priv String | toShortString()
Overrides java. Returns a short descriptive string to describe this object in log messages. |
| public String | Returns: a string describing thisMethodOverrides java. Returns a string describing this |
| annotationDefault | back to summary |
|---|---|
| private final byte[] annotationDefault | |
| annotations | back to summary |
|---|---|
| private final byte[] annotations | |
| callerSensitive | back to summary |
|---|---|
| private byte callerSensitive
| |
| clazz | back to summary |
|---|---|
| private final Class<?> clazz | |
| exceptionTypes | back to summary |
|---|---|
| private final Class<?>[] exceptionTypes | |
| genericInfo | back to summary |
|---|---|
| private transient volatile MethodRepository genericInfo | |
| hash | back to summary |
|---|---|
| private int hash | |
| methodAccessor | back to summary |
|---|---|
| private MethodAccessor methodAccessor
| |
| modifiers | back to summary |
|---|---|
| private final int modifiers | |
| name | back to summary |
|---|---|
| private final String name | |
| parameterAnnotations | back to summary |
|---|---|
| private final byte[] parameterAnnotations | |
| parameterTypes | back to summary |
|---|---|
| private final Class<?>[] parameterTypes | |
| returnType | back to summary |
|---|---|
| private final Class<?> returnType | |
| root | back to summary |
|---|---|
| private Method root Methods are mutable due to | |
| signature | back to summary |
|---|---|
| private final transient String signature | |
| slot | back to summary |
|---|---|
| private final int slot | |
| Method | back to summary |
|---|---|
| pack-priv Method(Class<?> declaringClass, String name, Class<?>[] parameterTypes, Class<?> returnType, Class<?>[] checkedExceptions, int modifiers, int slot, String signature, byte[] annotations, byte[] parameterAnnotations, byte[] annotationDefault) Package-private constructor | |
| acquireMethodAccessor | back to summary |
|---|---|
| private MethodAccessor acquireMethodAccessor() | |
| appendModifiers | back to summary |
|---|---|
| pack-priv void appendModifiers(StringBuilder sb) Implements abstract java.
| |
| checkCanSetAccessible | back to summary |
|---|---|
| pack-priv void checkCanSetAccessible(Class<?> caller) Overrides java. Doc from java. If the given AccessibleObject is a
| |
| copy | back to summary |
|---|---|
| pack-priv Method copy() Package-private routine (exposed to java.lang.Class via ReflectAccess) which returns a copy of this Method. The copy's "root" field points to this Method. | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Compares this | |
| getAnnotatedReturnType | back to summary |
|---|---|
| public AnnotatedType getAnnotatedReturnType() Implements abstract java. Doc from java. Returns an
| |
| getAnnotation | back to summary |
|---|---|
| public <T extends Annotation> T getAnnotation(Class<T> annotationClass) Overrides java. Implements java. Doc from java. Returns this element's annotation for the specified type if such an annotation is present, else null.
| |
| getAnnotationBytes | back to summary |
|---|---|
| pack-priv byte[] getAnnotationBytes() Implements abstract java. Doc from java. Accessor method to allow code sharing
| |
| getDeclaredAnnotations | back to summary |
|---|---|
| public Annotation[] getDeclaredAnnotations() Overrides java. Implements java. Doc from java. Returns annotations that are directly present on this element. This method ignores inherited annotations. If there are no annotations directly present on this element, the return value is an array of length 0. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.
| |
| getDeclaringClass | back to summary |
|---|---|
| public Class Implements abstract java. Implements java. Returns the
| |
| getDefaultValue | back to summary |
|---|---|
| public Object getDefaultValue() Returns the default value for the annotation member represented by
this
| |
| getExceptionTypes | back to summary |
|---|---|
| public Class Implements abstract java. Doc from java. Returns an array of
| |
| getFactory | back to summary |
|---|---|
| private GenericsFactory getFactory() | |
| getGenericExceptionTypes | back to summary |
|---|---|
| public Type[] getGenericExceptionTypes() Overrides java. Doc from java. Returns an array of If an exception type is a type variable or a parameterized type, it is created. Otherwise, it is resolved.
| |
| getGenericInfo | back to summary |
|---|---|
| pack-priv MethodRepository getGenericInfo() Implements abstract java.
| |
| getGenericParameterTypes | back to summary |
|---|---|
| public Type[] getGenericParameterTypes() Overrides java. Doc from java. Returns an array of If a formal parameter type is a parameterized type,
the If a formal parameter type is a type variable or a parameterized type, it is created. Otherwise, it is resolved.
| |
| getGenericReturnType | back to summary |
|---|---|
| public Type getGenericReturnType() Returns a If the return type is a parameterized type,
the If the return type is a type variable or a parameterized type, it is created. Otherwise, it is resolved.
| |
| getGenericSignature | back to summary |
|---|---|
| private String getGenericSignature() | |
| getMethodAccessor | back to summary |
|---|---|
| pack-priv MethodAccessor getMethodAccessor() | |
| getModifiers | back to summary |
|---|---|
| public int getModifiers() Implements abstract java. Implements java. Doc from java. Returns the Java language modifiers for the executable represented by this object.
| |
| getName | back to summary |
|---|---|
| public String getName() Implements abstract java. Implements java. Returns the name of the method represented by this
| |
| getParameterAnnotations | back to summary |
|---|---|
| public Annotation[][] getParameterAnnotations() Implements abstract java. Doc from java. Returns an array of arrays of Note that any annotations returned by this method are declaration annotations.
| |
| getParameterCount | back to summary |
|---|---|
| public int getParameterCount() Implements abstract java. Doc from java. Returns the number of formal parameters (whether explicitly declared or implicitly declared or neither) for the executable represented by this object.
| |
| getParameterTypes | back to summary |
|---|---|
| public Class Implements abstract java. Doc from java. Returns an array of
| |
| getReturnType | back to summary |
|---|---|
| public Class Returns a
| |
| getRoot | back to summary |
|---|---|
| pack-priv Method getRoot() Overrides java. Doc from java. Returns the root AccessibleObject; or null if this object is the root. All subclasses override this method.
| |
| getSharedExceptionTypes | back to summary |
|---|---|
| pack-priv Class Implements abstract java.
| |
| getSharedParameterTypes | back to summary |
|---|---|
| pack-priv Class Implements abstract java.
| |
| getTypeParameters | back to summary |
|---|---|
| public TypeVariable Implements abstract java. Implements java. Doc from java. Returns an array of
| |
| handleParameterNumberMismatch | back to summary |
|---|---|
| pack-priv boolean handleParameterNumberMismatch(int resultLength, Class<?>[] parameterTypes) Implements abstract java.
| |
| hasGenericInformation | back to summary |
|---|---|
| pack-priv boolean hasGenericInformation() Implements abstract java. Doc from java. Does the Executable have generic information.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns a hashcode for this | |
| invoke | back to summary |
|---|---|
| public Object invoke(Object obj, Object... args) throws IllegalAccessException, InvocationTargetException Invokes the underlying method represented by this If the underlying method is static, then the specified If the number of formal parameters required by the underlying method is
0, the supplied If the underlying method is an instance method, it is invoked using dynamic method lookup as documented in The Java Language Specification, section 15.12.4.4; in particular, overriding based on the runtime type of the target object may occur. If the underlying method is static, the class that declared the method is initialized if it has not already been initialized. If the method completes normally, the value it returns is returned to the caller of invoke; if the value has a primitive type, it is first appropriately wrapped in an object. However, if the value has the type of an array of a primitive type, the elements of the array are not wrapped in objects; in other words, an array of primitive type is returned. If the underlying method return type is void, the invocation returns null.
| |
| invoke | back to summary |
|---|---|
| private Object invoke(Object obj, Object[] args, Class<?> caller) throws IllegalAccessException, InvocationTargetException This is to support MethodHandle calling caller-sensitive Method::invoke that may invoke a caller-sensitive method in order to get the original caller class (not the injected invoker). If this adapter is not presented, MethodHandle invoking Method::invoke will get an invoker class, a hidden nestmate of the original caller class, that becomes the caller class invoking Method::invoke.
| |
| isBridge | back to summary |
|---|---|
| public boolean isBridge() Returns API Note A bridge method is a synthetic method created by a Java compiler alongside a method originating from the source code. Bridge methods are used by Java compilers in various circumstances to span differences in Java programming language semantics and JVM semantics. One example use of bridge methods is as a technique for a
Java compiler to support covariant overrides, where a
subclass overrides a method and gives the new method a more
specific return type than the method in the superclass. While
the Java language specification forbids a class declaring two
methods with the same parameter types but a different return
type, the virtual machine does not. A common case where
covariant overrides are used is for a
and EnumSet<E> declares its language-level covariant override
If this technique was being used, the resulting class file for
EnumSet would have two clone methods, one
returning EnumSet<E> and the second a bridge method
returning Object. The bridge method is a JVM-level
override of Object.clone(). The body of the clone bridge method calls its non-bridge counterpart and
returns its result.
| |
| isCallerSensitive | back to summary |
|---|---|
| private boolean isCallerSensitive() | |
| isDefault | back to summary |
|---|---|
| public boolean isDefault() Returns
| |
| isSynthetic | back to summary |
|---|---|
| public boolean isSynthetic() Overrides java. Implements java. Doc from java. Returns
| |
| isVarArgs | back to summary |
|---|---|
| public boolean isVarArgs() Overrides java. Doc from java. Returns
| |
| setAccessible | back to summary |
|---|---|
| public void setAccessible(boolean flag) Overrides java. Doc from java. Set the This method may be used by a caller in class
This method may be used by JNI code
with no caller class on the stack to enable access to a
This method cannot be used to enable access to private members, members with default (package) access, protected instance members, or protected constructors when the declaring class is in a different module to the caller and the package containing the declaring class is not open to the caller's module.
| |
| setMethodAccessor | back to summary |
|---|---|
| pack-priv void setMethodAccessor(MethodAccessor accessor) | |
| specificToGenericStringHeader | back to summary |
|---|---|
| pack-priv void specificToGenericStringHeader(StringBuilder sb) Implements abstract java. Doc from java. Generate toGenericString header information specific to a method or constructor.
| |
| specificToStringHeader | back to summary |
|---|---|
| pack-priv void specificToStringHeader(StringBuilder sb) Implements abstract java. Doc from java. Generate toString header information specific to a method or constructor.
| |
| toGenericString | back to summary |
|---|---|
| public String toGenericString() Overrides java. Returns a string describing this The access modifiers are placed in canonical order as
specified by "The Java Language Specification". This is
| |
| toShortSignature | back to summary |
|---|---|
| pack-priv String toShortSignature() | |
| toShortString | back to summary |
|---|---|
| pack-priv String toShortString() Overrides java. Doc from java. Returns a short descriptive string to describe this object in log messages.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string describing this public boolean java.lang.Object.equals(java.lang.Object) The access modifiers are placed in canonical order as
specified by "The Java Language Specification". This is
| |