Comparable<MethodInfo>
public class MethodInfo extends Object implements Comparable<MethodInfo>
Constructor | Description |
---|---|
MethodInfo(String className,
String methodName,
List<AnnotationInfo> methodAnnotationInfo,
int modifiers,
String typeDescriptorStr,
String typeSignatureStr,
String[] parameterNames,
int[] parameterModifiers,
AnnotationInfo[][] parameterAnnotationInfo) |
Modifier and Type | Method | Description |
---|---|---|
int |
compareTo(MethodInfo other) |
Sort in order of class name, method name, then type descriptor.
|
boolean |
equals(Object obj) |
Test class name, method name and type descriptor for equals().
|
List<AnnotationInfo> |
getAnnotationInfo() |
Get a list of annotations on this method, along with any annotation parameter values.
|
List<String> |
getAnnotationNames() |
Returns the names of annotations on the method.
|
List<Class<?>> |
getAnnotationTypes() |
Returns a list of
Class<?> references for the annotations on this method. |
String |
getClassName() |
Get the name of the class this method is part of.
|
String |
getMethodName() |
Returns the name of the method.
|
int |
getModifiers() |
Returns the modifier bits for the method.
|
String |
getModifiersStr() |
Get the method modifiers as a String, e.g.
|
int |
getNumParameters() |
Get the number of parameters of the method.
|
AnnotationInfo[][] |
getParameterAnnotationInfo() |
Returns the annotations on each method parameter (along with any annotation parameters, wrapped in
AnnotationInfo objects) if any parameters have annotations, else returns null.
|
String[][] |
getParameterAnnotationNames() |
Returns the unique annotation names for annotations on each method parameter, if any parameters have
annotations, else returns null.
|
Class<?>[][] |
getParameterAnnotationTypes() |
Returns the unique annotation types for annotations on each method parameter, if any parameters have
annotations, else returns null.
|
MethodParameterInfo[] |
getParameterInfo() |
Get the available information on method parameters.
|
int[] |
getParameterModifiers() |
Returns the parameter modifiers, if available (only available in classfiles compiled in JDK8 or above using
the -parameters commandline switch, or code compiled with Kotlin or some other language), otherwise returns
null if the parameter modifiers are not known.
|
String[] |
getParameterModifierStrs() |
Returns the parameter modifiers as a string (e.g.
|
String[] |
getParameterNames() |
Returns the method parameter names, if available (only available in classfiles compiled in JDK8 or above
using the -parameters commandline switch), otherwise returns null if the parameter names are not known.
|
Class<?>[] |
getParameterTypes() |
Returns the parameter types for the method.
|
TypeSignature[] |
getParameterTypeSignatures() |
Returns the parameter type signatures for the method.
|
Class<?> |
getResultType() |
Returns the return type for the method as a Class reference.
|
TypeSignature |
getResultTypeDescriptor() |
Returns the result type descriptor for the method (without any type parameters).
|
TypeSignature |
getResultTypeSignature() |
Returns the result type signature for the method (with type parameters, if present).
|
Class<?>[] |
getThrowsTypes() |
Returns the types of exceptions the method may throw.
|
ClassRefOrTypeVariableSignature[] |
getThrowsTypeSignatures() |
Returns the types of exceptions the method may throw, in string representation, e.g.
|
String[] |
getThrowsTypeStrs() |
Returns the types of exceptions the method may throw, in string representation, e.g.
|
MethodTypeSignature |
getTypeDescriptor() |
Returns the parsed type descriptor for the method, which will not include type parameters.
|
String |
getTypeDescriptorStr() |
Returns the low-level internal type descriptor for the method, e.g.
|
TypeParameter[] |
getTypeParameters() |
Returns the type parameters of the method.
|
String[] |
getTypeParameterStrs() |
Returns the type parameters of the method, in string representation, e.g.
|
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.
|
String |
getTypeSignatureStr() |
Returns the low-level internal type Signature for the method, e.g.
|
int |
hashCode() |
Use hash code of class name, method name and type descriptor.
|
boolean |
isBridge() |
Returns true if this method is a bridge method.
|
boolean |
isConstructor() |
Returns true if this method is a constructor.
|
boolean |
isFinal() |
Returns true if this method is final.
|
boolean |
isNative() |
Returns true if this method is a native method.
|
boolean |
isPackagePrivate() |
Returns true if this method is package-private.
|
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 |
isSynchronized() |
Returns true if this method is synchronized.
|
boolean |
isVarArgs() |
Returns true if this method is a varargs method.
|
String |
toString() |
Get a string representation of the method.
|
public MethodInfo(String className, String methodName, List<AnnotationInfo> methodAnnotationInfo, int modifiers, String typeDescriptorStr, String typeSignatureStr, String[] parameterNames, int[] parameterModifiers, AnnotationInfo[][] parameterAnnotationInfo)
className
- The name of the enclosing class.methodName
- The name of the method.methodAnnotationInfo
- The list of AnnotationInfo
objects for any annotations on the method.modifiers
- The method modifier bits.typeDescriptorStr
- The internal method type descriptor string.typeSignatureStr
- The internal method type signature string, or null if none.parameterNames
- The parameter names.parameterModifiers
- The parameter modifiers.parameterAnnotationInfo
- The parameter AnnotationInfo
.public int getModifiers()
public String getModifiersStr()
getModifiers()
.public String getClassName()
public String getMethodName()
"<init>"
, and private static class
initializer blocks are named "<clinit>"
.public String getTypeDescriptorStr()
"(Ljava/util/List;)V"
. This is
the internal type descriptor used by the JVM, so does not include type parameters (due to type erasure), and
does include any synthetic and/or mandated parameters generated by the compiler. See also
getTypeDescriptor()
.public String getTypeSignatureStr()
"(Ljava/util/List<Ljava/lang/String;>)V"
. This may or may not include synthetic and/or mandated
parameters, depending on the compiler. May be null, if there is no type signature in the classfile. See also
getTypeDescriptorStr()
.public MethodTypeSignature getTypeDescriptor()
public MethodTypeSignature getTypeSignature()
public MethodTypeSignature getTypeSignatureOrTypeDescriptor()
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 isPackagePrivate()
public boolean isStatic()
public boolean isFinal()
public boolean isSynchronized()
public boolean isBridge()
public boolean isVarArgs()
public boolean isNative()
public MethodParameterInfo[] getParameterInfo()
MethodParameterInfo
objects for the method parameters, one per parameter.public int getNumParameters()
getParameterInfo().size()
.public Class<?>[] getParameterTypes() throws IllegalArgumentException
getParameterInfo()
and get the parameter information from the
returned list of MethodParameterInfo
objects, since this method calls that to compile its results.
Note that this calls Class.forName() on the parameter types, which will cause the class to be loaded, and possibly initialized. If the class is initialized, this can trigger side effects.
Class<?>
references for the method parameter types.IllegalArgumentException
- if the parameter types of the method could not be loaded.public TypeSignature[] getParameterTypeSignatures()
getParameterInfo()
and get the parameter information from the
returned list of MethodParameterInfo
objects, since this method calls that to compile its results.public String[] getParameterNames()
getParameterInfo()
and get the parameter information from the
returned list of MethodParameterInfo
objects, since this method calls that to compile its results.public int[] getParameterModifiers()
Flag bits:
getParameterInfo()
and get the parameter information from the
returned list of MethodParameterInfo
objects, since this method calls that to compile its results.public String[] getParameterModifierStrs()
getParameterInfo()
and get the parameter information from the
returned list of MethodParameterInfo
objects, since this method calls that to compile its results.public AnnotationInfo[][] getParameterAnnotationInfo()
getParameterInfo()
and get the parameter information from the
returned list of MethodParameterInfo
objects, since this method calls that to compile its results.AnnotationInfo
objects, or null if no
parameter annotations are present.public String[][] getParameterAnnotationNames()
getParameterInfo()
and get the parameter information from the
returned list of MethodParameterInfo
objects, since this method calls that to compile its results.public Class<?>[][] getParameterAnnotationTypes()
getParameterInfo()
and get the parameter information from the
returned list of MethodParameterInfo
objects, since this method calls that to compile its results.public TypeSignature getResultTypeSignature()
public TypeSignature getResultTypeDescriptor()
public Class<?> getResultType() throws IllegalArgumentException
Class.forName()
on the return type, which will cause the class to
be loaded, and possibly initialized. If the class is initialized, this can trigger side effects.Class<?>
reference.IllegalArgumentException
- if the return type for the method could not be loaded.public ClassRefOrTypeVariableSignature[] getThrowsTypeSignatures()
["com.abc.BadException", "<X>"]
.public Class<?>[] getThrowsTypes()
public String[] getThrowsTypeStrs()
["com.abc.BadException", "<X>"]
.public TypeParameter[] getTypeParameters()
public String[] getTypeParameterStrs()
["<X>",
"<Y>"]
.["<X>",
"<Y>"]
. If the method has no type parameters, returns a zero-sized array.public List<String> getAnnotationNames()
public List<Class<?>> getAnnotationTypes() throws IllegalArgumentException
Class<?>
references for the annotations on this method. Note that this calls
Class.forName() on the annotation types, which will cause each annotation class to be loaded.Class<?>
references for the annotations on this method, or the empty list if none.IllegalArgumentException
- if the annotation type could not be loaded.public List<AnnotationInfo> getAnnotationInfo()
AnnotationInfo
objects, or the empty list if none.public boolean equals(Object obj)
public int hashCode()
public int compareTo(MethodInfo other)
compareTo
in interface Comparable<MethodInfo>
Copyright © 2018. All rights reserved.