public class MethodInfo extends java.lang.Object implements java.lang.Comparable<MethodInfo>, HasName
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.Class<?> |
classRef
The class ref, once the class is loaded.
|
protected ScanResult |
scanResult
The scan result.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(MethodInfo other)
Sort in order of class name, method name, then type descriptor.
|
boolean |
equals(java.lang.Object obj)
Test class name, method name and type descriptor for equals().
|
protected void |
findReferencedClassInfo(java.util.Map<java.lang.String,ClassInfo> classNameToClassInfo,
java.util.Set<ClassInfo> refdClassInfo,
LogNode log)
Get
ClassInfo objects for any classes referenced in the type descriptor or type signature. |
AnnotationInfoList |
getAnnotationInfo()
Get a list of annotations on this method, along with any annotation parameter values.
|
AnnotationInfo |
getAnnotationInfo(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Get a the non-
Repeatable annotation on this method, or null if the method does not have the
annotation. |
AnnotationInfo |
getAnnotationInfo(java.lang.String annotationName)
Get a the named non-
Repeatable annotation on this method, or null if the method does not have the
named annotation. |
AnnotationInfoList |
getAnnotationInfoRepeatable(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Get a the
Repeatable annotation on this method, or the empty list if the method does not have the
annotation. |
AnnotationInfoList |
getAnnotationInfoRepeatable(java.lang.String annotationName)
Get a the named
Repeatable annotation on this method, or the empty list if the method does not have
the named annotation. |
ClassInfo |
getClassInfo()
Get the
ClassInfo object for the class that declares this method. |
java.lang.String |
getClassName()
Get the name of the class that declares this method.
|
int |
getModifiers()
Returns the modifier bits for the method.
|
java.lang.String |
getModifiersStr()
Get the method modifiers as a String, e.g.
|
java.lang.String |
getName()
Returns the name of the method.
|
MethodParameterInfo[] |
getParameterInfo()
Get the available information on method parameters.
|
MethodTypeSignature |
getTypeDescriptor()
Returns the parsed type descriptor for the method, which will not include type parameters.
|
java.lang.String |
getTypeDescriptorStr()
Returns the type descriptor string for the method, which will not include type parameters.
|
MethodTypeSignature |
getTypeSignature()
Returns the parsed type signature for the method, possibly including type parameters.
|
MethodTypeSignature |
getTypeSignatureOrTypeDescriptor()
Returns the parsed type signature for the method, possibly including type parameters.
|
java.lang.String |
getTypeSignatureOrTypeDescriptorStr()
Returns the type signature string for the method, possibly including type parameters.
|
java.lang.String |
getTypeSignatureStr()
Returns the type signature string for the method, possibly including type parameters.
|
boolean |
hasAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Check if this method has the annotation.
|
boolean |
hasAnnotation(java.lang.String annotationName)
Check if this method has the named annotation.
|
boolean |
hasBody()
Returns true if this method has a body (i.e. has an implementation in the containing class).
|
int |
hashCode()
Use hashcode of class name, method name and type descriptor.
|
boolean |
hasParameterAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Check if this method has a parameter with the annotation.
|
boolean |
hasParameterAnnotation(java.lang.String annotationName)
Check if this method has a parameter with the named annotation.
|
boolean |
isAbstract()
Returns true if this method is abstract.
|
boolean |
isBridge()
Returns true if this method is a bridge method.
|
boolean |
isConstructor()
Returns true if this method is a constructor.
|
boolean |
isDefault()
Returns true if this is a default method (i.e. if this is a method in an interface and the method has a
body).
|
boolean |
isFinal()
Returns true if this method is final.
|
boolean |
isNative()
Returns true if this method is a native method.
|
boolean |
isPrivate()
Returns true if this method is private.
|
boolean |
isProtected()
Returns true if this method is protected.
|
boolean |
isPublic()
Returns true if this method is public.
|
boolean |
isStatic()
Returns true if this method is static.
|
boolean |
isStrict()
Returns true if this method is strict.
|
boolean |
isSynchronized()
Returns true if this method is synchronized.
|
boolean |
isSynthetic()
Returns true if this method is synthetic.
|
boolean |
isVarArgs()
Returns true if this method is a varargs method.
|
java.lang.reflect.Constructor<?> |
loadClassAndGetConstructor()
Load the class this constructor is associated with, and get the
Constructor reference for this
constructor. |
java.lang.reflect.Method |
loadClassAndGetMethod()
Load the class this method is associated with, and get the
Method reference for this method. |
java.lang.String |
toString()
Render to string.
|
protected void |
toString(boolean useSimpleNames,
java.lang.StringBuilder buf)
Get a string representation of the method.
|
java.lang.String |
toStringWithSimpleNames()
Render to string, using only simple
names for classes.
|
protected transient ScanResult scanResult
protected transient java.lang.Class<?> classRef
public java.lang.String getName()
"<init>", and private static class
initializer blocks are named "<clinit>".public int getModifiers()
public java.lang.String getModifiersStr()
getModifiers().public ClassInfo getClassInfo()
ClassInfo object for the class that declares this method.ClassInfo object for the declaring class.getClassName()public MethodTypeSignature getTypeDescriptor()
getTypeSignature() instead.public java.lang.String getTypeDescriptorStr()
getTypeSignatureStr() instead.public MethodTypeSignature getTypeSignature()
getTypeDescriptor()
instead.java.lang.IllegalArgumentException - if the method type signature cannot be parsed (this should only be thrown in the case of
classfile corruption, or a compiler bug that causes an invalid type signature to be written to
the classfile).public java.lang.String getTypeSignatureStr()
getTypeDescriptorStr() instead.public MethodTypeSignature getTypeSignatureOrTypeDescriptor()
public java.lang.String getTypeSignatureOrTypeDescriptorStr()
public boolean isConstructor()
"<init>". This returns false for private static class initializer blocks, which are named
"<clinit>".public boolean isPublic()
public boolean isPrivate()
public boolean isProtected()
public boolean isStatic()
public boolean isFinal()
public boolean isSynchronized()
public boolean isBridge()
public boolean isSynthetic()
public boolean isVarArgs()
public boolean isNative()
public boolean isAbstract()
public boolean isStrict()
public boolean hasBody()
public boolean isDefault()
public MethodParameterInfo[] getParameterInfo()
MethodParameterInfo objects for the method parameters, one per parameter.public AnnotationInfoList getAnnotationInfo()
AnnotationInfo objects, or the empty list if none.public AnnotationInfo getAnnotationInfo(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Repeatable annotation on this method, or null if the method does not have the
annotation. (Use getAnnotationInfoRepeatable(Class) for Repeatable annotations.)annotation - The annotation.AnnotationInfo object representing the annotation on this method, or null if the method
does not have the annotation.public AnnotationInfo getAnnotationInfo(java.lang.String annotationName)
Repeatable annotation on this method, or null if the method does not have the
named annotation. (Use getAnnotationInfoRepeatable(String) for Repeatable annotations.)annotationName - The annotation name.AnnotationInfo object representing the named annotation on this method, or null if the
method does not have the named annotation.public AnnotationInfoList getAnnotationInfoRepeatable(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Repeatable annotation on this method, or the empty list if the method does not have the
annotation.annotation - The annotation.AnnotationInfoList containing all instances of the annotation on this method, or the empty
list if the method does not have the annotation.public AnnotationInfoList getAnnotationInfoRepeatable(java.lang.String annotationName)
Repeatable annotation on this method, or the empty list if the method does not have
the named annotation.annotationName - The annotation name.AnnotationInfoList containing all instances of the named annotation on this method, or the
empty list if the method does not have the named annotation.public boolean hasAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
annotation - The annotation.public boolean hasAnnotation(java.lang.String annotationName)
annotationName - The name of an annotation.public boolean hasParameterAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
annotation - The method parameter annotation.public boolean hasParameterAnnotation(java.lang.String annotationName)
annotationName - The name of a method parameter annotation.public java.lang.reflect.Method loadClassAndGetMethod()
throws java.lang.IllegalArgumentException
Method reference for this method. Only
call this if isConstructor() returns false, otherwise an IllegalArgumentException will be
thrown. Instead call loadClassAndGetConstructor() for constructors.Method reference for this method.java.lang.IllegalArgumentException - if the method does not exist, or if the method is a constructor.public java.lang.reflect.Constructor<?> loadClassAndGetConstructor()
throws java.lang.IllegalArgumentException
Constructor reference for this
constructor. Only call this if isConstructor() returns true, otherwise an
IllegalArgumentException will be thrown. Instead call loadClassAndGetMethod() for non-method
constructors.Constructor reference for this constructor.java.lang.IllegalArgumentException - if the constructor does not exist, or if the method is not a constructor.public java.lang.String getClassName()
getClassInfo()protected void findReferencedClassInfo(java.util.Map<java.lang.String,ClassInfo> classNameToClassInfo, java.util.Set<ClassInfo> refdClassInfo, LogNode log)
ClassInfo objects for any classes referenced in the type descriptor or type signature.classNameToClassInfo - the map from class name to ClassInfo.refdClassInfo - the referenced class infolog - the logpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the object to compare for equalitypublic int hashCode()
hashCode in class java.lang.Objectpublic int compareTo(MethodInfo other)
compareTo in interface java.lang.Comparable<MethodInfo>other - the other MethodInfo to compare.protected void toString(boolean useSimpleNames,
java.lang.StringBuilder buf)
"<init>", and private
static class initializer blocks are named "<clinit>".useSimpleNames - the use simple namesbuf - the bufpublic java.lang.String toStringWithSimpleNames()
public java.lang.String toString()
toString in class java.lang.Object