Package java.lang.reflect
Class AbstractMethod
- java.lang.Object
-
- java.lang.reflect.AccessibleObject
-
- java.lang.reflect.AbstractMethod
-
- All Implemented Interfaces:
AnnotatedElement
- Direct Known Subclasses:
Constructor,Method
public abstract class AbstractMethod extends AccessibleObject
This class represents an abstract method. Abstract methods are either methods or constructors.
-
-
Field Summary
Fields Modifier and Type Field Description protected intaccessFlagsBits encoding access (e.g. public, private) as well as other runtime specific flagsprotected longartMethodThe ArtMethod associated with this Method, requried for dispatching due to entrypoints Classloader is held live by the declaring class.protected Class<?>declaringClassMethod's declaring classprotected Class<?>declaringClassOfOverriddenMethodOverriden method's declaring class (same as declaringClass unless declaringClass is a proxy class)protected intdexMethodIndexThe method index of this method within its defining dex file
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMethod()Hidden to workaround b/16828157.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected intcompareParameters(Class<?>[] params)protected booleanequalMethodParameters(Class<?>[] params)booleanequals(Object other)Returns true ifotherhas the same declaring class, name, parameters and return type as this method.intgetAccessFlags()<T extends Annotation>
TgetAnnotation(Class<T> annotationClass)Returns, for this element, the annotation with the specified type, ornullif no annotation with the specified type is present (including inherited annotations).Annotation[]getAnnotations()Returns, for this element, an array containing all annotations (including inherited annotations).Annotation[]getDeclaredAnnotations()Returns, for this element, all annotations that are explicitly declared (not inherited).intgetDexMethodIndex()Returns the index of this method's ID in its dex file.abstract StringgetName()Returns the name of the method or constructor represented by this instance.abstract Annotation[][]getParameterAnnotations()Returns an array of arrays that represent the annotations of the formal parameters of this method.booleanisAnnotationPresent(Class<? extends Annotation> annotationType)Indicates whether or not this element has an annotation with the specified annotation type (including inherited annotations).-
Methods inherited from class java.lang.reflect.AccessibleObject
isAccessible, setAccessible, setAccessible
-
-
-
-
Field Detail
-
accessFlags
protected int accessFlags
Bits encoding access (e.g. public, private) as well as other runtime specific flags
-
artMethod
protected long artMethod
The ArtMethod associated with this Method, requried for dispatching due to entrypoints Classloader is held live by the declaring class. Hidden to workaround b/16828157.
-
declaringClass
protected Class<?> declaringClass
Method's declaring class
-
declaringClassOfOverriddenMethod
protected Class<?> declaringClassOfOverriddenMethod
Overriden method's declaring class (same as declaringClass unless declaringClass is a proxy class)
-
dexMethodIndex
protected int dexMethodIndex
The method index of this method within its defining dex file
-
-
Method Detail
-
getAnnotation
public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
Description copied from interface:AnnotatedElementReturns, for this element, the annotation with the specified type, ornullif no annotation with the specified type is present (including inherited annotations).- Specified by:
getAnnotationin interfaceAnnotatedElement- Overrides:
getAnnotationin classAccessibleObject- Parameters:
annotationClass- the type of the annotation to search for- Returns:
- the annotation with the specified type or
null
-
getAccessFlags
public final int getAccessFlags()
-
getDexMethodIndex
public final int getDexMethodIndex()
Returns the index of this method's ID in its dex file.
-
getName
public abstract String getName()
Returns the name of the method or constructor represented by this instance.- Returns:
- the name of this method
-
equals
public boolean equals(Object other)
Returns true ifotherhas the same declaring class, name, parameters and return type as this method.- Overrides:
equalsin classObject- Parameters:
other- the object to compare this instance with.- Returns:
trueif the specified object is equal to thisObject;falseotherwise.- See Also:
Object.hashCode()
-
getDeclaredAnnotations
public Annotation[] getDeclaredAnnotations()
Description copied from interface:AnnotatedElementReturns, for this element, all annotations that are explicitly declared (not inherited). If there are no declared annotations present, this method returns a zero length array.- Specified by:
getDeclaredAnnotationsin interfaceAnnotatedElement- Overrides:
getDeclaredAnnotationsin classAccessibleObject- Returns:
- an array of annotations declared for this element
-
isAnnotationPresent
public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
Description copied from interface:AnnotatedElementIndicates whether or not this element has an annotation with the specified annotation type (including inherited annotations).- Specified by:
isAnnotationPresentin interfaceAnnotatedElement- Overrides:
isAnnotationPresentin classAccessibleObject- Parameters:
annotationType- the type of the annotation to search for- Returns:
trueif the annotation exists,falseotherwise
-
getAnnotations
public Annotation[] getAnnotations()
Description copied from interface:AnnotatedElementReturns, for this element, an array containing all annotations (including inherited annotations). If there are no annotations present, this method returns a zero length array.- Specified by:
getAnnotationsin interfaceAnnotatedElement- Overrides:
getAnnotationsin classAccessibleObject- Returns:
- an array of all annotations for this element
-
getParameterAnnotations
public abstract Annotation[][] getParameterAnnotations()
Returns an array of arrays that represent the annotations of the formal parameters of this method. If there are no parameters on this method, then an empty array is returned. If there are no annotations set, then and array of empty arrays is returned.- Returns:
- an array of arrays of
Annotationinstances
-
equalMethodParameters
protected boolean equalMethodParameters(Class<?>[] params)
-
compareParameters
protected int compareParameters(Class<?>[] params)
-
-