Class MethodInfo
- java.lang.Object
-
- edu.umd.cs.findbugs.classfile.FieldOrMethodDescriptor
-
- edu.umd.cs.findbugs.classfile.MethodDescriptor
-
- edu.umd.cs.findbugs.classfile.analysis.MethodInfo
-
- All Implemented Interfaces:
AccessibleEntity
,ClassMember
,ComparableMethod
,XMethod
,AnnotatedObject
,FieldOrMethodName
,java.io.Serializable
,java.lang.Comparable<ComparableMethod>
public class MethodInfo extends MethodDescriptor implements XMethod
- Author:
- pugh
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MethodInfo.Builder
static class
MethodInfo.MethodInfoDatabase
-
Field Summary
Fields Modifier and Type Field Description static MethodInfo[]
EMPTY_ARRAY
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAnnotation(AnnotationValue annotationValue)
Destructively add an annotation.void
addParameterAnnotation(int param, AnnotationValue annotationValue)
Destructively add a parameter annotation.XMethod
bridgeFrom()
XMethod
bridgeTo()
If nonnull, then this method is a synthetic method that overrides a method in a superclass.int
compareTo(ComparableMethod rhs)
int
getAccessFlags()
Get the entity's access flags.FieldDescriptor
getAccessMethodForField()
MethodDescriptor
getAccessMethodForMethod()
AnnotationValue
getAnnotation(ClassDescriptor desc)
Get the AnnotationValue of annotation applied directly to the method.java.util.Collection<ClassDescriptor>
getAnnotationDescriptors()
Get ClassDescriptors (annotation classes) of annotations applied directly to this method.java.util.Collection<AnnotationValue>
getAnnotations()
Get collection of all AnnotationValues applied directly to the method.java.lang.String
getClassName()
Get the full (dotted) name of the class (if the object represents a class) or the class the entity is defined in (if a field or method).AnnotatedObject
getContainingScope()
java.lang.annotation.ElementType
getElementType()
static java.util.IdentityHashMap<MethodInfo,java.lang.Void>
getInvokeDynamicMethods()
int
getMethodCallCount()
MethodDescriptor
getMethodDescriptor()
int
getNumParams()
java.lang.String
getPackageName()
Get the (dotted) name of the package in which the entity is defined.AnnotationValue
getParameterAnnotation(int param, ClassDescriptor desc)
Get the AnnotationValue of annotation applied directly to given parameter.java.util.Collection<ClassDescriptor>
getParameterAnnotationDescriptors(int param)
Get ClassDescriptors (annotation classes) of annotations applied directly to this method's parameters.java.util.Collection<AnnotationValue>
getParameterAnnotations(int param)
Get collection of all AnnotationValues applied directly to given parameter.java.lang.String
getSourceSignature()
Get the signature representing the field/method's type, including generic typejava.lang.String[]
getThrownExceptions()
boolean
hasBackBranch()
boolean
hasParameterAnnotations()
boolean
isAbstract()
boolean
isBridge()
Is this a bridge method?boolean
isDeprecated()
Is the entity deprecated?boolean
isFinal()
Is the entity final?boolean
isIdentity()
Is this an identity methodboolean
isNative()
boolean
isPrivate()
Is the entity private?boolean
isProtected()
Is the entity protected?boolean
isPublic()
Is the entity public?boolean
isResolved()
Did we find a declaration of this entity?boolean
isReturnTypeReferenceType()
boolean
isStub()
boolean
isSynchronized()
boolean
isSynthetic()
Is the entity synthetic?boolean
isUnconditionalThrower()
boolean
isUnsupported()
boolean
isVarArgs()
boolean
isVariableSynthetic(int param)
Is the variable synthetic?static MethodInfo[]
newArray(int sz)
XMethod
resolveAccessMethodForMethod()
boolean
usesConcurrency()
boolean
usesInvokeDynamic()
-
Methods inherited from class edu.umd.cs.findbugs.classfile.MethodDescriptor
equals
-
Methods inherited from class edu.umd.cs.findbugs.classfile.FieldOrMethodDescriptor
compareTo, compareTo, getClassDescriptor, getName, getNameSigHashCode, getNameSigHashCode, getSignature, getSlashedClassName, hashCode, haveEqualFields, isStatic, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface edu.umd.cs.findbugs.ba.AccessibleEntity
getClassDescriptor, isStatic
-
Methods inherited from interface edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject
getClassDescriptor
-
Methods inherited from interface edu.umd.cs.findbugs.ba.ClassMember
getName, getSignature
-
Methods inherited from interface edu.umd.cs.findbugs.classfile.FieldOrMethodName
getClassDescriptor, isStatic
-
-
-
-
Field Detail
-
EMPTY_ARRAY
public static final MethodInfo[] EMPTY_ARRAY
-
-
Method Detail
-
newArray
public static MethodInfo[] newArray(int sz)
-
getInvokeDynamicMethods
public static java.util.IdentityHashMap<MethodInfo,java.lang.Void> getInvokeDynamicMethods()
-
getThrownExceptions
@CheckForNull public java.lang.String[] getThrownExceptions()
- Specified by:
getThrownExceptions
in interfaceXMethod
- Returns:
- the exceptions this method is declared to throw
-
isUnconditionalThrower
public boolean isUnconditionalThrower()
- Specified by:
isUnconditionalThrower
in interfaceXMethod
- Returns:
- does this method unconditionally throw an exception?
-
isIdentity
public boolean isIdentity()
Description copied from interface:XMethod
Is this an identity method- Specified by:
isIdentity
in interfaceXMethod
-
usesInvokeDynamic
public boolean usesInvokeDynamic()
- Specified by:
usesInvokeDynamic
in interfaceXMethod
-
isUnsupported
public boolean isUnsupported()
- Specified by:
isUnsupported
in interfaceXMethod
- Returns:
- does this method unconditionally throw an UnsupportedOperationException?
-
getNumParams
public int getNumParams()
- Specified by:
getNumParams
in interfaceXMethod
-
isVariableSynthetic
public boolean isVariableSynthetic(int param)
Description copied from interface:XMethod
Is the variable synthetic?- Specified by:
isVariableSynthetic
in interfaceXMethod
-
getMethodCallCount
public int getMethodCallCount()
-
isAbstract
public boolean isAbstract()
- Specified by:
isAbstract
in interfaceXMethod
-
isSynchronized
public boolean isSynchronized()
- Specified by:
isSynchronized
in interfaceXMethod
-
isBridge
public boolean isBridge()
Description copied from interface:XMethod
Is this a bridge method?
-
isReturnTypeReferenceType
public boolean isReturnTypeReferenceType()
- Specified by:
isReturnTypeReferenceType
in interfaceXMethod
- Returns:
- true if method's return type is a reference type, false otherwise
-
getClassName
@DottedClassName public java.lang.String getClassName()
Description copied from interface:ClassMember
Get the full (dotted) name of the class (if the object represents a class) or the class the entity is defined in (if a field or method).- Specified by:
getClassName
in interfaceClassMember
-
getPackageName
@DottedClassName public java.lang.String getPackageName()
Description copied from interface:ClassMember
Get the (dotted) name of the package in which the entity is defined.- Specified by:
getPackageName
in interfaceClassMember
-
getSourceSignature
public java.lang.String getSourceSignature()
Description copied from interface:ClassMember
Get the signature representing the field/method's type, including generic type- Specified by:
getSourceSignature
in interfaceClassMember
-
compareTo
public int compareTo(ComparableMethod rhs)
- Specified by:
compareTo
in interfacejava.lang.Comparable<ComparableMethod>
- Overrides:
compareTo
in classMethodDescriptor
-
getAccessFlags
public int getAccessFlags()
Description copied from interface:AccessibleEntity
Get the entity's access flags.- Specified by:
getAccessFlags
in interfaceAccessibleEntity
-
isFinal
public boolean isFinal()
Description copied from interface:AccessibleEntity
Is the entity final?- Specified by:
isFinal
in interfaceAccessibleEntity
-
isPrivate
public boolean isPrivate()
Description copied from interface:AccessibleEntity
Is the entity private?- Specified by:
isPrivate
in interfaceAccessibleEntity
-
isDeprecated
public boolean isDeprecated()
Description copied from interface:AccessibleEntity
Is the entity deprecated?- Specified by:
isDeprecated
in interfaceAccessibleEntity
-
isProtected
public boolean isProtected()
Description copied from interface:AccessibleEntity
Is the entity protected?- Specified by:
isProtected
in interfaceAccessibleEntity
-
isPublic
public boolean isPublic()
Description copied from interface:AccessibleEntity
Is the entity public?- Specified by:
isPublic
in interfaceAccessibleEntity
-
isSynthetic
public boolean isSynthetic()
Description copied from interface:AccessibleEntity
Is the entity synthetic?- Specified by:
isSynthetic
in interfaceAccessibleEntity
- Specified by:
isSynthetic
in interfaceAnnotatedObject
-
isResolved
public boolean isResolved()
Description copied from interface:ClassMember
Did we find a declaration of this entity?- Specified by:
isResolved
in interfaceClassMember
-
getParameterAnnotationDescriptors
public java.util.Collection<ClassDescriptor> getParameterAnnotationDescriptors(int param)
Description copied from interface:XMethod
Get ClassDescriptors (annotation classes) of annotations applied directly to this method's parameters.- Specified by:
getParameterAnnotationDescriptors
in interfaceXMethod
- Parameters:
param
- parameter number (0 for first parameter)- Returns:
- ClassDescriptors of annotations applied directly to this method's parameters
-
hasParameterAnnotations
public boolean hasParameterAnnotations()
- Specified by:
hasParameterAnnotations
in interfaceXMethod
-
getParameterAnnotation
@Nullable public AnnotationValue getParameterAnnotation(int param, ClassDescriptor desc)
Description copied from interface:XMethod
Get the AnnotationValue of annotation applied directly to given parameter.- Specified by:
getParameterAnnotation
in interfaceXMethod
- Parameters:
param
- parameter number (0 for first parameter)desc
- ClassDescriptor of the annotation class- Returns:
- AnnotationValue annotating the parameter, or null if parameter is not annotated with this kind of annotation
-
getParameterAnnotations
public java.util.Collection<AnnotationValue> getParameterAnnotations(int param)
Description copied from interface:XMethod
Get collection of all AnnotationValues applied directly to given parameter.- Specified by:
getParameterAnnotations
in interfaceXMethod
- Parameters:
param
- parameter number (0 for first parameter)- Returns:
- Collection of all AnnotationValues applied directly to given parameter
-
getAnnotationDescriptors
public java.util.Collection<ClassDescriptor> getAnnotationDescriptors()
Description copied from interface:XMethod
Get ClassDescriptors (annotation classes) of annotations applied directly to this method.- Specified by:
getAnnotationDescriptors
in interfaceAnnotatedObject
- Specified by:
getAnnotationDescriptors
in interfaceXMethod
- Returns:
- ClassDescriptors of annotations applied directly to this method
-
getAnnotation
public AnnotationValue getAnnotation(ClassDescriptor desc)
Description copied from interface:XMethod
Get the AnnotationValue of annotation applied directly to the method.- Specified by:
getAnnotation
in interfaceAnnotatedObject
- Specified by:
getAnnotation
in interfaceXMethod
- Parameters:
desc
- ClassDescriptor of the annotation class- Returns:
- AnnotationValue annotating the method, or null if method is not annotated with this kind of annotation
-
getAnnotations
public java.util.Collection<AnnotationValue> getAnnotations()
Description copied from interface:XMethod
Get collection of all AnnotationValues applied directly to the method.- Specified by:
getAnnotations
in interfaceAnnotatedObject
- Specified by:
getAnnotations
in interfaceXMethod
- Returns:
- Collection of all AnnotationValues applied directly to the method
-
addAnnotation
public void addAnnotation(AnnotationValue annotationValue)
Destructively add an annotation. We do this for "built-in" annotations that might not be directly evident in the code. It's not a great idea in general, but we can get away with it as long as it's done early enough (i.e., before anyone asks what annotations this method has.)- Specified by:
addAnnotation
in interfaceXMethod
- Parameters:
annotationValue
- an AnnotationValue representing a method annotation
-
addParameterAnnotation
public void addParameterAnnotation(int param, AnnotationValue annotationValue)
Destructively add a parameter annotation.- Specified by:
addParameterAnnotation
in interfaceXMethod
- Parameters:
param
- parameter (0 == first parameter)annotationValue
- an AnnotationValue representing a parameter annotation
-
getMethodDescriptor
public MethodDescriptor getMethodDescriptor()
- Specified by:
getMethodDescriptor
in interfaceXMethod
- Returns:
- the MethodDescriptor identifying this object
-
getElementType
public java.lang.annotation.ElementType getElementType()
- Specified by:
getElementType
in interfaceAnnotatedObject
-
getContainingScope
@CheckForNull public AnnotatedObject getContainingScope()
- Specified by:
getContainingScope
in interfaceAnnotatedObject
-
isVarArgs
public boolean isVarArgs()
-
usesConcurrency
public boolean usesConcurrency()
- Specified by:
usesConcurrency
in interfaceXMethod
- Returns:
- does the method directly make use of concurrency/threads/synchronization?
-
hasBackBranch
public boolean hasBackBranch()
-
isStub
public boolean isStub()
-
getAccessMethodForMethod
@CheckForNull public MethodDescriptor getAccessMethodForMethod()
- Specified by:
getAccessMethodForMethod
in interfaceXMethod
-
getAccessMethodForField
@CheckForNull public FieldDescriptor getAccessMethodForField()
- Specified by:
getAccessMethodForField
in interfaceXMethod
-
bridgeFrom
public XMethod bridgeFrom()
- Specified by:
bridgeFrom
in interfaceXMethod
-
bridgeTo
public XMethod bridgeTo()
Description copied from interface:XMethod
If nonnull, then this method is a synthetic method that overrides a method in a superclass. This method simply forwards the call to the method it bridges to, which is a method with an identical name but possibly co-variant arguments and return values.
-
resolveAccessMethodForMethod
public XMethod resolveAccessMethodForMethod()
- Specified by:
resolveAccessMethodForMethod
in interfaceXMethod
-
-