public class MethodInfo extends Object implements Comparable<MethodInfo>
Constructor and Description |
---|
MethodInfo(String className,
String methodName,
int modifiers,
String typeDescriptorInternal,
String typeDescriptorHumanReadable,
String[] parameterNames,
int[] parameterAccessFlagsInternal,
List<AnnotationInfo> methodAnnotationInfo,
AnnotationInfo[][] parameterAnnotationInfo) |
Modifier and Type | Method and 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().
|
int |
getAccessFlags()
Returns the access flags of the method.
|
List<AnnotationInfo> |
getAnnotationInfo()
Get a list of annotations on this method, along with any annotation parameter values, wrapped in
AnnotationInfo objects, or the empty list if none.
|
List<String> |
getAnnotationNames()
Returns the names of annotations on the method, or the empty list if none.
|
List<Class<?>> |
getAnnotationTypes()
Returns a list of Class> references for the annotations on this method, or the empty list if none.
|
String |
getClassName()
Get the name of the class this method is part of.
|
String |
getMethodName()
Returns the name of the method.
|
String |
getModifiers()
Get the method modifiers as a string, e.g.
|
int[] |
getParameterAccessFlags()
Returns the parameter access flags, 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.
|
int[] |
getParameterAccessFlagsInternal()
Returns the parameter access flags, 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.
|
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.
|
String[] |
getParameterModifiers()
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.
|
Class<?>[] |
getParameterTypes()
Returns the parameter types for the method.
|
TypeParser.TypeSignature[] |
getParameterTypeSignatures()
Returns the parameter type signatures for the method.
|
String[] |
getParameterTypeStrs()
Returns the parameter types for the method in string representation, e.g.
|
Class<?> |
getReturnType()
Returns the return type for the method as a Class reference.
|
TypeParser.TypeSignature |
getReturnTypeSignature()
Returns the return type signature for the method.
|
String |
getReturnTypeStr()
Returns the return type for the method in string representation, e.g.
|
Class<?>[] |
getThrowsTypes()
Returns the types of exceptions the method may throw.
|
TypeParser.ClassTypeOrTypeVariableSignature[] |
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.
|
String |
getTypeDescriptor()
Returns the type descriptor for the method, e.g.
|
String |
getTypeDescriptorInternal()
Returns the internal type descriptor for the method, e.g.
|
TypeParser.TypeParameter[] |
getTypeParameters()
Returns the type parameters of the method.
|
String[] |
getTypeParameterStrs()
Returns the type parameters of the method, in string representation, e.g.
|
TypeParser.MethodSignature |
getTypeSignature()
Returns the Java type signature for the method.
|
TypeParser.MethodSignature |
getTypeSignatureInternal()
Returns the internal Java type signature for the method.
|
TypeParser.MethodSignature |
getTypeSignatureUnified()
Returns the unification of type signatures returned by and
getTypeSignature() and and
getTypeSignatureInternal() , i.e. |
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, int modifiers, String typeDescriptorInternal, String typeDescriptorHumanReadable, String[] parameterNames, int[] parameterAccessFlagsInternal, List<AnnotationInfo> methodAnnotationInfo, AnnotationInfo[][] parameterAnnotationInfo)
public String getModifiers()
public boolean isConstructor()
"<init>"
. This returns false for private static class initializer blocks, which are named
"<clinit>"
.public String getClassName()
public String getMethodName()
"<init>"
, and private static class
initializer blocks are named "<clinit>"
.public int getAccessFlags()
public String getTypeDescriptor()
getTypeDescriptorInternal()
.public String getTypeDescriptorInternal()
getTypeDescriptor()
.public TypeParser.MethodSignature getTypeSignature()
getTypeSignatureInternal()
and getTypeSignatureUnified()
.public TypeParser.MethodSignature getTypeSignatureInternal()
getTypeSignature()
and
getTypeSignatureUnified()
.public TypeParser.MethodSignature getTypeSignatureUnified()
getTypeSignature()
and and
getTypeSignatureInternal()
, i.e. returns all known type signature information, including any
available type parameters, and also any synthetic and/or mandated parameters.public TypeParser.TypeSignature getReturnTypeSignature()
public String getReturnTypeStr()
public Class<?> getReturnType() throws IllegalArgumentException
IllegalArgumentException
- if the return type for the method could not be loaded.public TypeParser.TypeSignature[] getParameterTypeSignatures()
public Class<?>[] getParameterTypes() throws IllegalArgumentException
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.
IllegalArgumentException
- if the parameter types of the method could not be loaded.public String[] getParameterTypeStrs()
["int",
"List<X>", "com.abc.XYZ"]
. If the method has no parameters, returns a zero-sized array.public TypeParser.ClassTypeOrTypeVariableSignature[] getThrowsTypeSignatures()
["com.abc.BadException", "<X>"]
. If the method throws no exceptions, returns a zero-sized array.public Class<?>[] getThrowsTypes()
public String[] getThrowsTypeStrs()
["com.abc.BadException", "<X>"]
. If the method throws no exceptions, returns a zero-sized array.public TypeParser.TypeParameter[] getTypeParameters()
public String[] getTypeParameterStrs()
["<X>",
"<Y>"]
. If the method has no type parameters, returns a zero-sized array.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 String[] getParameterNames()
Note that parameters may be unnamed, in which case the corresponding parameter name will be null.
public int[] getParameterAccessFlags()
getParameterAccessFlagsInternal()
.
Flag bits:
public int[] getParameterAccessFlagsInternal()
getParameterAccessFlags()
.
Flag bits:
public String[] getParameterModifiers()
public String[][] getParameterAnnotationNames()
public Class<?>[][] getParameterAnnotationTypes()
public AnnotationInfo[][] getParameterAnnotationInfo()
public List<String> getAnnotationNames()
public List<Class<?>> getAnnotationTypes() throws IllegalArgumentException
IllegalArgumentException
- if the annotation type could not be loaded.public List<AnnotationInfo> getAnnotationInfo()
public boolean equals(Object obj)
public int hashCode()
public int compareTo(MethodInfo other)
compareTo
in interface Comparable<MethodInfo>
Copyright © 2018. All rights reserved.