Top Description Fields Constructors Methods
io.github.classgraph

public Class MethodInfo

extends ClassMemberInfo
implements Comparable<MethodInfo>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable
Imports
java.lang.annotation.Annotation, .Repeatable, java.lang.reflect.Constructor, .Method, .Modifier, java.util.ArrayList, .Arrays, .List, .Map, .Set, io.github.classgraph.ClassInfo.RelType, .Classfile.MethodTypeAnnotationDecorator, nonapi.io.github.classgraph.types.ParseException, .TypeUtils, .TypeUtils.ModifierType, nonapi.io.github.classgraph.utils.Assert, .LogNode

Holds metadata about methods of a class encountered during a scan. All values are taken directly out of the classfile for the class.

Field Summary

Modifier and TypeField and Description
private boolean
hasBody

True if this method has a body.

private int
maxLineNum

The maximum line number for the body of this method, or 0 if unknown.

private int
minLineNum

The minimum line number for the body of this method, or 0 if unknown.

pack-priv AnnotationInfo[][]
parameterAnnotationInfo

Unaligned parameter annotations.

private transient MethodParameterInfo[]
parameterInfo

Aligned method parameter info.

private int[]
parameterModifiers

Unaligned parameter modifiers.

private String[]
parameterNames

Unaligned parameter names.

private String[]
private transient ClassInfoList
private transient List<Classfile.MethodTypeAnnotationDecorator>
typeAnnotationDecorators

The type annotation decorators for the MethodTypeSignature instance.

private transient MethodTypeSignature
typeDescriptor

The parsed type descriptor.

private transient MethodTypeSignature
typeSignature

The parsed type signature (or null if none).

Inherited from io.github.classgraph.ClassMemberInfo:
annotationInfodeclaringClassNamemodifiersnametypeDescriptorStrtypeSignatureStr

Constructor Summary

AccessConstructor and Description
pack-priv
MethodInfo()

Default constructor for deserialization.

pack-priv
MethodInfo(final String
The name of the enclosing class.
definingClassName
,
final String
The name of the method.
methodName
,
final AnnotationInfoList
The list of AnnotationInfo objects for any annotations on the method.
methodAnnotationInfo
,
final int
The method modifier bits.
modifiers
,
final String
The internal method type descriptor string.
typeDescriptorStr
,
final String
The internal method type signature string, or null if none.
typeSignatureStr
,
final String[]
The parameter names.
parameterNames
,
final int[]
The parameter modifiers.
parameterModifiers
,
final AnnotationInfo[][]
The parameter AnnotationInfo.
parameterAnnotationInfo
,
final boolean
True if this method has a body.
hasBody
,
final int
The minimum line number for the body of this method, or 0 if unknown.
minLineNum
,
final int
The maximum line number for the body of this method, or 0 if unknown.
maxLineNum
,
final List<Classfile.MethodTypeAnnotationDecorator>
Decorator lambdas for method type annotations.
methodTypeAnnotationDecorators
,
final String[]
exceptions thrown by this method.
thrownExceptionNames
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the result of the comparison.
compareTo
(final MethodInfo
the other MethodInfo to compare.
other
)

Implements java.lang.Comparable.compareTo.

Sort in order of class name, method name, then type descriptor.

public boolean

Returns:

true if equal
equals
(final Object
the object to compare for equality
obj
)

Overrides java.lang.Object.equals.

Test class name, method name and type descriptor for equals().

protected void
findReferencedClassInfo(final Map<String, ClassInfo>
the map from class name to ClassInfo.
classNameToClassInfo
,
final Set<ClassInfo>
the referenced class info
refdClassInfo
,
final LogNode
the log
log
)

Overrides io.github.classgraph.ScanResultObject.findReferencedClassInfo.

Get ClassInfo objects for any classes referenced in the type descriptor or type signature.

public int

Returns:

The line number of the last non-empty line in the body of this method, or 0 if unknown.
getMaxLineNum
()

The line number of the last non-empty line in the body of this method, or 0 if unknown.

public int

Returns:

The line number of the first non-empty line in the body of this method, or 0 if unknown.
getMinLineNum
()

The line number of the first non-empty line in the body of this method, or 0 if unknown.

public String

Returns:

The modifiers for the method, as a String.
getModifiersStr
()

Implements abstract io.github.classgraph.ClassMemberInfo.getModifiersStr.

Get the method modifiers as a String, e.g. "public static final".

public String

Returns:

The name of the method.
getName
()

Overrides io.github.classgraph.ClassMemberInfo.getName.

Implements io.github.classgraph.HasName.getName.

Returns the name of the method.

public MethodParameterInfo[]

Returns:

The MethodParameterInfo objects for the method parameters, one per parameter.
getParameterInfo
()

Get the available information on method parameters.

public String[]

Returns:

The exceptions thrown by the method, as an array (the array may be empty).
getThrownExceptionNames
()

Returns the exceptions thrown by the method, as an array.

public ClassInfoList

Returns:

The list of exceptions thrown by the method, as a ClassInfoList (the list may be empty).
getThrownExceptions
()

Returns the list of exceptions thrown by the method, as a ClassInfoList.

public MethodTypeSignature

Returns:

The parsed type descriptor for the method.
getTypeDescriptor
()

Implements abstract io.github.classgraph.ClassMemberInfo.getTypeDescriptor.

Returns the parsed type descriptor for the method, which will not include type parameters.

public MethodTypeSignature

Returns:

The parsed type signature for the method, or null if not available.
getTypeSignature
()

Implements abstract io.github.classgraph.ClassMemberInfo.getTypeSignature.

Returns the parsed type signature for the method, possibly including type parameters.

public MethodTypeSignature

Returns:

The parsed type signature for the method, or if not available, the parsed type descriptor for the method.
getTypeSignatureOrTypeDescriptor
()

Implements abstract io.github.classgraph.ClassMemberInfo.getTypeSignatureOrTypeDescriptor.

Returns the parsed type signature for the method, possibly including type parameters.

pack-priv void
handleRepeatableAnnotations(final Set<String>
the names of all repeatable annotations
allRepeatableAnnotationNames
)

Handle Repeatable annotations.

public boolean

Returns:

True if this method has a body.
hasBody
()

Returns true if this method has a body (i.e. has an implementation in the containing class).

public int

Returns:

the hashcode
hashCode
()

Overrides java.lang.Object.hashCode.

Use hashcode of class name, method name and type descriptor.

public boolean

Returns:

true if this method has a parameter with the annotation.
hasParameterAnnotation
(final Class<? extends Annotation>
The method parameter annotation.
annotation
)

Check if this method has a parameter with the annotation.

public boolean

Returns:

true if this method has a parameter with the named annotation.
hasParameterAnnotation
(final String
The name of a method parameter annotation.
annotationName
)

Check if this method has a parameter with the named annotation.

public boolean

Returns:

True if this method is abstract.
isAbstract
()

Returns true if this method is abstract.

public boolean

Returns:

True if this is a bridge method.
isBridge
()

Returns true if this method is a bridge method.

public boolean

Returns:

True if this method is a constructor.
isConstructor
()

Returns true if this method is a constructor.

public boolean

Returns:

True if this is a default method.
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).

public boolean

Returns:

True if this method is native.
isNative
()

Returns true if this method is a native method.

public boolean

Returns:

True if this method is strict.
isStrict
()

Returns true if this method is strict.

public boolean

Returns:

True if this method is synchronized.
isSynchronized
()

Returns true if this method is synchronized.

public boolean

Returns:

True if this is a varargs method.
isVarArgs
()

Returns true if this method is a varargs method.

public Constructor<?>

Returns:

The Constructor reference for this constructor.
loadClassAndGetConstructor
()

Load the class this constructor is associated with, and get the Constructor reference for this constructor.

public Method

Returns:

The Method reference for this method.
loadClassAndGetMethod
()

Load the class this method is associated with, and get the Method reference for this method.

private Class<?>[]

Returns:

An array of the Class references for each method parameter.
loadParameterClasses
()

Load and return the classes of each of the method parameters.

pack-priv void
setScanResult(final ScanResult
the scan result
scanResult
)

Overrides io.github.classgraph.ScanResultObject.setScanResult.

Set ScanResult backreferences in info objects after scan has completed.

protected void
toString(final boolean
the use simple names
useSimpleNames
,
final StringBuilder
the buf
buf
)

Implements abstract io.github.classgraph.ScanResultObject.toString.

Get a string representation of the method.

Inherited from io.github.classgraph.ClassMemberInfo:
getAnnotationInfogetAnnotationInfogetAnnotationInfogetAnnotationInfoRepeatablegetAnnotationInfoRepeatablegetClassInfogetClassNamegetModifiersgetTypeDescriptorStrgetTypeSignatureOrTypeDescriptorStrgetTypeSignatureStrhasAnnotationhasAnnotationisFinalisPrivateisProtectedisPublicisStaticisSynthetic

Field Detail

hasBodyback to summary
private boolean hasBody

True if this method has a body.

maxLineNumback to summary
private int maxLineNum

The maximum line number for the body of this method, or 0 if unknown.

minLineNumback to summary
private int minLineNum

The minimum line number for the body of this method, or 0 if unknown.

parameterAnnotationInfoback to summary
pack-priv AnnotationInfo[][] parameterAnnotationInfo

Unaligned parameter annotations.

parameterInfoback to summary
private transient MethodParameterInfo[] parameterInfo

Aligned method parameter info.

parameterModifiersback to summary
private int[] parameterModifiers

Unaligned parameter modifiers. These are only produced in JDK8+, and only if the commandline switch `-parameters` is provided at compiletime.

parameterNamesback to summary
private String[] parameterNames

Unaligned parameter names. These are only produced in JDK8+, and only if the commandline switch `-parameters` is provided at compiletime.

thrownExceptionNamesback to summary
private String[] thrownExceptionNames
thrownExceptionsback to summary
private transient ClassInfoList thrownExceptions
typeAnnotationDecoratorsback to summary
private transient List<Classfile.MethodTypeAnnotationDecorator> typeAnnotationDecorators

The type annotation decorators for the MethodTypeSignature instance.

typeDescriptorback to summary
private transient MethodTypeSignature typeDescriptor

The parsed type descriptor.

typeSignatureback to summary
private transient MethodTypeSignature typeSignature

The parsed type signature (or null if none). Method parameter types are unaligned.

Constructor Detail

MethodInfoback to summary
pack-priv MethodInfo()

Default constructor for deserialization.

MethodInfoback to summary
pack-priv MethodInfo(final String definingClassName, final String methodName, final AnnotationInfoList methodAnnotationInfo, final int modifiers, final String typeDescriptorStr, final String typeSignatureStr, final String[] parameterNames, final int[] parameterModifiers, final AnnotationInfo[][] parameterAnnotationInfo, final boolean hasBody, final int minLineNum, final int maxLineNum, final List<Classfile.MethodTypeAnnotationDecorator> methodTypeAnnotationDecorators, final String[] thrownExceptionNames)

Constructor.

Parameters
definingClassName:String

The name of the enclosing class.

methodName:String

The name of the method.

methodAnnotationInfo:AnnotationInfoList

The list of AnnotationInfo objects for any annotations on the method.

modifiers:int

The method modifier bits.

typeDescriptorStr:String

The internal method type descriptor string.

typeSignatureStr:String

The internal method type signature string, or null if none.

parameterNames:String[]

The parameter names.

parameterModifiers:int[]

The parameter modifiers.

parameterAnnotationInfo:AnnotationInfo[][]

The parameter AnnotationInfo.

hasBody:boolean

True if this method has a body.

minLineNum:int

The minimum line number for the body of this method, or 0 if unknown.

maxLineNum:int

The maximum line number for the body of this method, or 0 if unknown.

methodTypeAnnotationDecorators:List<Classfile.MethodTypeAnnotationDecorator>

Decorator lambdas for method type annotations.

thrownExceptionNames:String[]

exceptions thrown by this method.

Method Detail

compareToback to summary
public int compareTo(final MethodInfo other)

Implements java.lang.Comparable.compareTo.

Sort in order of class name, method name, then type descriptor.

Parameters
other:MethodInfo

the other MethodInfo to compare.

Returns:int

the result of the comparison.

Annotations
@Override
equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Test class name, method name and type descriptor for equals().

Parameters
obj:Object

the object to compare for equality

Returns:boolean

true if equal

Annotations
@Override
findReferencedClassInfoback to summary
protected void findReferencedClassInfo(final Map<String, ClassInfo> classNameToClassInfo, final Set<ClassInfo> refdClassInfo, final LogNode log)

Overrides io.github.classgraph.ScanResultObject.findReferencedClassInfo.

Get ClassInfo objects for any classes referenced in the type descriptor or type signature.

Parameters
classNameToClassInfo:Map<String, ClassInfo>

the map from class name to ClassInfo.

refdClassInfo:Set<ClassInfo>

the referenced class info

log:LogNode

Doc from io.github.classgraph.ScanResultObject.findReferencedClassInfo.

the log

Annotations
@Override
getMaxLineNumback to summary
public int getMaxLineNum()

The line number of the last non-empty line in the body of this method, or 0 if unknown.

Returns:int

The line number of the last non-empty line in the body of this method, or 0 if unknown.

getMinLineNumback to summary
public int getMinLineNum()

The line number of the first non-empty line in the body of this method, or 0 if unknown.

Returns:int

The line number of the first non-empty line in the body of this method, or 0 if unknown.

getModifiersStrback to summary
public String getModifiersStr()

Implements abstract io.github.classgraph.ClassMemberInfo.getModifiersStr.

Get the method modifiers as a String, e.g. "public static final". For the modifier bits, call getModifiers().

Returns:String

The modifiers for the method, as a String.

Annotations
@Override
getNameback to summary
public String getName()

Overrides io.github.classgraph.ClassMemberInfo.getName.

Implements io.github.classgraph.HasName.getName.

Returns the name of the method. Note that constructors are named "<init>", and private static class initializer blocks are named "<clinit>".

Returns:String

The name of the method.

Annotations
@Override
getParameterInfoback to summary
public MethodParameterInfo[] getParameterInfo()

Get the available information on method parameters.

Returns:MethodParameterInfo[]

The MethodParameterInfo objects for the method parameters, one per parameter.

getThrownExceptionNamesback to summary
public String[] getThrownExceptionNames()

Returns the exceptions thrown by the method, as an array.

Returns:String[]

The exceptions thrown by the method, as an array (the array may be empty).

getThrownExceptionsback to summary
public ClassInfoList getThrownExceptions()

Returns the list of exceptions thrown by the method, as a ClassInfoList.

Returns:ClassInfoList

The list of exceptions thrown by the method, as a ClassInfoList (the list may be empty).

getTypeDescriptorback to summary
public MethodTypeSignature getTypeDescriptor()

Implements abstract io.github.classgraph.ClassMemberInfo.getTypeDescriptor.

Returns the parsed type descriptor for the method, which will not include type parameters. If you need generic type parameters, call getTypeSignature() instead.

Returns:MethodTypeSignature

The parsed type descriptor for the method.

Annotations
@Override
getTypeSignatureback to summary
public MethodTypeSignature getTypeSignature()

Implements abstract io.github.classgraph.ClassMemberInfo.getTypeSignature.

Returns the parsed type signature for the method, possibly including type parameters. If this returns null, indicating that no type signature information is available for this method, call getTypeDescriptor() instead.

Returns:MethodTypeSignature

The parsed type signature for the method, or null if not available.

Annotations
@Override
Exceptions
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).
getTypeSignatureOrTypeDescriptorback to summary
public MethodTypeSignature getTypeSignatureOrTypeDescriptor()

Implements abstract io.github.classgraph.ClassMemberInfo.getTypeSignatureOrTypeDescriptor.

Returns the parsed type signature for the method, possibly including type parameters. If the type signature string is null, indicating that no type signature information is available for this method, returns the parsed type descriptor instead.

Returns:MethodTypeSignature

The parsed type signature for the method, or if not available, the parsed type descriptor for the method.

Annotations
@Override
handleRepeatableAnnotationsback to summary
pack-priv void handleRepeatableAnnotations(final Set<String> allRepeatableAnnotationNames)

Handle Repeatable annotations.

Parameters
allRepeatableAnnotationNames:Set<String>

the names of all repeatable annotations

hasBodyback to summary
public boolean hasBody()

Returns true if this method has a body (i.e. has an implementation in the containing class).

Returns:boolean

True if this method has a body.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Use hashcode of class name, method name and type descriptor.

Returns:int

the hashcode

Annotations
@Override
hasParameterAnnotationback to summary
public boolean hasParameterAnnotation(final Class<? extends Annotation> annotation)

Check if this method has a parameter with the annotation.

Parameters
annotation:Class<? extends Annotation>

The method parameter annotation.

Returns:boolean

true if this method has a parameter with the annotation.

hasParameterAnnotationback to summary
public boolean hasParameterAnnotation(final String annotationName)

Check if this method has a parameter with the named annotation.

Parameters
annotationName:String

The name of a method parameter annotation.

Returns:boolean

true if this method has a parameter with the named annotation.

isAbstractback to summary
public boolean isAbstract()

Returns true if this method is abstract.

Returns:boolean

True if this method is abstract.

isBridgeback to summary
public boolean isBridge()

Returns true if this method is a bridge method.

Returns:boolean

True if this is a bridge method.

isConstructorback to summary
public boolean isConstructor()

Returns true if this method is a constructor. Constructors have the method name "<init>". This returns false for private static class initializer blocks, which are named "<clinit>".

Returns:boolean

True if this method is a constructor.

isDefaultback to summary
public 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).

Returns:boolean

True if this is a default method.

isNativeback to summary
public boolean isNative()

Returns true if this method is a native method.

Returns:boolean

True if this method is native.

isStrictback to summary
public boolean isStrict()

Returns true if this method is strict.

Returns:boolean

True if this method is strict.

isSynchronizedback to summary
public boolean isSynchronized()

Returns true if this method is synchronized.

Returns:boolean

True if this method is synchronized.

isVarArgsback to summary
public boolean isVarArgs()

Returns true if this method is a varargs method.

Returns:boolean

True if this is a varargs method.

loadClassAndGetConstructorback to summary
public Constructor<?> loadClassAndGetConstructor() throws IllegalArgumentException

Load the class this constructor is associated with, and get the 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.

Returns:Constructor<?>

The Constructor reference for this constructor.

Exceptions
IllegalArgumentException:
  • If the method's class can't be loaded
  • If the constructor does not exist
  • If the method is not a constructor
  • If one of the constructor's parameters references an unknown class
loadClassAndGetMethodback to summary
public Method loadClassAndGetMethod() throws IllegalArgumentException

Load the class this method is associated with, and get the Method reference for this method. Only call this if isConstructor() returns false, otherwise an IllegalArgumentException will be thrown. Instead call loadClassAndGetConstructor() for constructors.

Returns:Method

The Method reference for this method.

Exceptions
IllegalArgumentException:
  • If the method's class can't be loaded
  • If the method does not exist
  • If the method is a constructor
  • If one of the method's parameters references an unknown class
  • If the method's return type references an unknown class
loadParameterClassesback to summary
private Class<?>[] loadParameterClasses()

Load and return the classes of each of the method parameters.

Returns:Class<?>[]

An array of the Class references for each method parameter.

setScanResultback to summary
pack-priv void setScanResult(final ScanResult scanResult)

Overrides io.github.classgraph.ScanResultObject.setScanResult.

Doc from io.github.classgraph.ScanResultObject.setScanResult.

Set ScanResult backreferences in info objects after scan has completed.

Parameters
scanResult:ScanResult

the scan result

Annotations
@Override
toStringback to summary
protected void toString(final boolean useSimpleNames, final StringBuilder buf)

Implements abstract io.github.classgraph.ScanResultObject.toString.

Get a string representation of the method. Note that constructors are named "<init>", and private static class initializer blocks are named "<clinit>".

Parameters
useSimpleNames:boolean

the use simple names

buf:StringBuilder

the buf

Annotations
@Override