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
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMethodInfo.Builderstatic classMethodInfo.MethodInfoDatabase
-
Field Summary
Fields Modifier and Type Field Description (package private) intaccessFlagsstatic MethodInfo[]EMPTY_ARRAY(package private) java.lang.String[]exceptions(package private) booleanhasBackBranch(package private) booleanhasPolymorphicSignature(package private) booleanisStub(package private) java.util.Map<ClassDescriptor,AnnotationValue>methodAnnotations(package private) intmethodCallCount(package private) java.util.Map<java.lang.Integer,java.util.Map<ClassDescriptor,AnnotationValue>>methodParameterAnnotations(package private) java.lang.StringmethodSourceSignature(package private) booleanusesConcurrency(package private) longvariableIsSynthetic
-
Constructor Summary
Constructors Constructor Description MethodInfo(java.lang.String className, java.lang.String methodName, java.lang.String methodSignature, java.lang.String methodSourceSignature, int accessFlags, boolean isUnconditionalThrower, boolean isUnsupported, boolean usesConcurrency, boolean hasBackBranch, boolean isStub, boolean isIdentity, boolean usesInvokeDynamic, int methodCallCount, java.lang.String[] exceptions, MethodDescriptor accessMethodForMethod, FieldDescriptor accessMethodForField, java.util.Map<ClassDescriptor,AnnotationValue> methodAnnotations, java.util.Map<java.lang.Integer,java.util.Map<ClassDescriptor,AnnotationValue>> methodParameterAnnotations, long variableIsSynthetic)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAnnotation(AnnotationValue annotationValue)Destructively add an annotation.voidaddParameterAnnotation(int param, AnnotationValue annotationValue)Destructively add a parameter annotation.XMethodbridgeFrom()XMethodbridgeTo()If nonnull, then this method is a synthetic method that overrides a method in a superclass.private booleancheckFlag(int flag)intcompareTo(ComparableMethod rhs)private booleancomputeHasPolymorphicSignature(java.util.Map<ClassDescriptor,AnnotationValue> methodAnnotations)intgetAccessFlags()Get the entity's access flags.(package private) static java.util.IdentityHashMap<MethodInfo,FieldDescriptor>getAccessmethodforfield()FieldDescriptorgetAccessMethodForField()(package private) static java.util.IdentityHashMap<MethodInfo,MethodDescriptor>getAccessmethodformethod()MethodDescriptorgetAccessMethodForMethod()AnnotationValuegetAnnotation(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.StringgetClassName()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).AnnotatedObjectgetContainingScope()(package private) static MethodInfo.MethodInfoDatabasegetDatabase()java.lang.annotation.ElementTypegetElementType()(package private) static java.util.IdentityHashMap<MethodInfo,java.lang.Void>getIdentitymethods()static java.util.IdentityHashMap<MethodInfo,java.lang.Void>getInvokeDynamicMethods()intgetMethodCallCount()MethodDescriptorgetMethodDescriptor()intgetNumParams()java.lang.StringgetPackageName()Get the (dotted) name of the package in which the entity is defined.AnnotationValuegetParameterAnnotation(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.StringgetSourceSignature()Get the signature representing the field/method's type, including generic typejava.lang.String[]getThrownExceptions()(package private) static java.util.IdentityHashMap<MethodInfo,java.lang.Void>getUnconditionalthrowers()(package private) static java.util.IdentityHashMap<MethodInfo,java.lang.Void>getUnsupportedmethods()booleanhasBackBranch()booleanhasParameterAnnotations()booleanhasPolymorphicSignature()Seejava.lang.invoke.MethodHandle.PolymorphicSignaturebooleanisAbstract()booleanisBridge()Is this a bridge method?booleanisDeprecated()Is the entity deprecated?booleanisFinal()Is the entity final?booleanisIdentity()Is this an identity methodbooleanisNative()booleanisPrivate()Is the entity private?booleanisProtected()Is the entity protected?booleanisPublic()Is the entity public?booleanisResolved()Did we find a declaration of this entity?booleanisReturnTypeReferenceType()booleanisStub()booleanisSynchronized()booleanisSynthetic()Is the entity synthetic?booleanisUnconditionalThrower()booleanisUnsupported()booleanisVarArgs()booleanisVariableSynthetic(int param)Is the variable synthetic?static MethodInfo[]newArray(int sz)XMethodresolveAccessMethodForMethod()booleanusesConcurrency()booleanusesInvokeDynamic()MethodInfowithSignature(java.lang.String otherMethodSignature)-
Methods inherited from class edu.umd.cs.findbugs.classfile.MethodDescriptor
equals, isAccessMethod
-
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
-
Methods inherited from interface edu.umd.cs.findbugs.ba.XMethod
isAccessMethod
-
-
-
-
Field Detail
-
EMPTY_ARRAY
public static final MethodInfo[] EMPTY_ARRAY
-
accessFlags
final int accessFlags
-
variableIsSynthetic
final long variableIsSynthetic
-
methodCallCount
final int methodCallCount
-
usesConcurrency
final boolean usesConcurrency
-
hasBackBranch
final boolean hasBackBranch
-
isStub
final boolean isStub
-
hasPolymorphicSignature
final boolean hasPolymorphicSignature
-
methodSourceSignature
final java.lang.String methodSourceSignature
-
exceptions
@CheckForNull final java.lang.String[] exceptions
-
methodAnnotations
java.util.Map<ClassDescriptor,AnnotationValue> methodAnnotations
-
methodParameterAnnotations
java.util.Map<java.lang.Integer,java.util.Map<ClassDescriptor,AnnotationValue>> methodParameterAnnotations
-
-
Constructor Detail
-
MethodInfo
MethodInfo(@SlashedClassName java.lang.String className, java.lang.String methodName, java.lang.String methodSignature, java.lang.String methodSourceSignature, int accessFlags, boolean isUnconditionalThrower, boolean isUnsupported, boolean usesConcurrency, boolean hasBackBranch, boolean isStub, boolean isIdentity, boolean usesInvokeDynamic, int methodCallCount, @CheckForNull java.lang.String[] exceptions, @CheckForNull MethodDescriptor accessMethodForMethod, @CheckForNull FieldDescriptor accessMethodForField, java.util.Map<ClassDescriptor,AnnotationValue> methodAnnotations, java.util.Map<java.lang.Integer,java.util.Map<ClassDescriptor,AnnotationValue>> methodParameterAnnotations, long variableIsSynthetic)
-
-
Method Detail
-
newArray
public static MethodInfo[] newArray(int sz)
-
getDatabase
static MethodInfo.MethodInfoDatabase getDatabase()
- Returns:
- Returns the database.
-
getUnconditionalthrowers
static java.util.IdentityHashMap<MethodInfo,java.lang.Void> getUnconditionalthrowers()
-
getUnsupportedmethods
static java.util.IdentityHashMap<MethodInfo,java.lang.Void> getUnsupportedmethods()
-
getAccessmethodformethod
static java.util.IdentityHashMap<MethodInfo,MethodDescriptor> getAccessmethodformethod()
-
getAccessmethodforfield
static java.util.IdentityHashMap<MethodInfo,FieldDescriptor> getAccessmethodforfield()
-
getIdentitymethods
static java.util.IdentityHashMap<MethodInfo,java.lang.Void> getIdentitymethods()
-
getInvokeDynamicMethods
public static java.util.IdentityHashMap<MethodInfo,java.lang.Void> getInvokeDynamicMethods()
-
computeHasPolymorphicSignature
private boolean computeHasPolymorphicSignature(java.util.Map<ClassDescriptor,AnnotationValue> methodAnnotations)
-
getThrownExceptions
@CheckForNull public java.lang.String[] getThrownExceptions()
- Specified by:
getThrownExceptionsin interfaceXMethod- Returns:
- the exceptions this method is declared to throw
-
isUnconditionalThrower
public boolean isUnconditionalThrower()
- Specified by:
isUnconditionalThrowerin interfaceXMethod- Returns:
- does this method unconditionally throw an exception?
-
isIdentity
public boolean isIdentity()
Description copied from interface:XMethodIs this an identity method- Specified by:
isIdentityin interfaceXMethod
-
usesInvokeDynamic
public boolean usesInvokeDynamic()
- Specified by:
usesInvokeDynamicin interfaceXMethod
-
isUnsupported
public boolean isUnsupported()
- Specified by:
isUnsupportedin interfaceXMethod- Returns:
- does this method unconditionally throw an UnsupportedOperationException?
-
getNumParams
public int getNumParams()
- Specified by:
getNumParamsin interfaceXMethod
-
isVariableSynthetic
public boolean isVariableSynthetic(int param)
Description copied from interface:XMethodIs the variable synthetic?- Specified by:
isVariableSyntheticin interfaceXMethod
-
getMethodCallCount
public int getMethodCallCount()
-
checkFlag
private boolean checkFlag(int flag)
-
isAbstract
public boolean isAbstract()
- Specified by:
isAbstractin interfaceXMethod
-
isSynchronized
public boolean isSynchronized()
- Specified by:
isSynchronizedin interfaceXMethod
-
isBridge
public boolean isBridge()
Description copied from interface:XMethodIs this a bridge method?
-
isReturnTypeReferenceType
public boolean isReturnTypeReferenceType()
- Specified by:
isReturnTypeReferenceTypein 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:ClassMemberGet 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:
getClassNamein interfaceClassMember
-
getPackageName
@DottedClassName public java.lang.String getPackageName()
Description copied from interface:ClassMemberGet the (dotted) name of the package in which the entity is defined.- Specified by:
getPackageNamein interfaceClassMember
-
getSourceSignature
public java.lang.String getSourceSignature()
Description copied from interface:ClassMemberGet the signature representing the field/method's type, including generic type- Specified by:
getSourceSignaturein interfaceClassMember
-
compareTo
public int compareTo(ComparableMethod rhs)
- Specified by:
compareToin interfacejava.lang.Comparable<ComparableMethod>- Overrides:
compareToin classMethodDescriptor
-
getAccessFlags
public int getAccessFlags()
Description copied from interface:AccessibleEntityGet the entity's access flags.- Specified by:
getAccessFlagsin interfaceAccessibleEntity
-
isFinal
public boolean isFinal()
Description copied from interface:AccessibleEntityIs the entity final?- Specified by:
isFinalin interfaceAccessibleEntity
-
isPrivate
public boolean isPrivate()
Description copied from interface:AccessibleEntityIs the entity private?- Specified by:
isPrivatein interfaceAccessibleEntity
-
isDeprecated
public boolean isDeprecated()
Description copied from interface:AccessibleEntityIs the entity deprecated?- Specified by:
isDeprecatedin interfaceAccessibleEntity
-
isProtected
public boolean isProtected()
Description copied from interface:AccessibleEntityIs the entity protected?- Specified by:
isProtectedin interfaceAccessibleEntity
-
isPublic
public boolean isPublic()
Description copied from interface:AccessibleEntityIs the entity public?- Specified by:
isPublicin interfaceAccessibleEntity
-
isSynthetic
public boolean isSynthetic()
Description copied from interface:AccessibleEntityIs the entity synthetic?- Specified by:
isSyntheticin interfaceAccessibleEntity- Specified by:
isSyntheticin interfaceAnnotatedObject
-
isResolved
public boolean isResolved()
Description copied from interface:ClassMemberDid we find a declaration of this entity?- Specified by:
isResolvedin interfaceClassMember
-
getParameterAnnotationDescriptors
public java.util.Collection<ClassDescriptor> getParameterAnnotationDescriptors(int param)
Description copied from interface:XMethodGet ClassDescriptors (annotation classes) of annotations applied directly to this method's parameters.- Specified by:
getParameterAnnotationDescriptorsin 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:
hasParameterAnnotationsin interfaceXMethod
-
getParameterAnnotation
@Nullable public AnnotationValue getParameterAnnotation(int param, ClassDescriptor desc)
Description copied from interface:XMethodGet the AnnotationValue of annotation applied directly to given parameter.- Specified by:
getParameterAnnotationin 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:XMethodGet collection of all AnnotationValues applied directly to given parameter.- Specified by:
getParameterAnnotationsin 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:XMethodGet ClassDescriptors (annotation classes) of annotations applied directly to this method.- Specified by:
getAnnotationDescriptorsin interfaceAnnotatedObject- Specified by:
getAnnotationDescriptorsin interfaceXMethod- Returns:
- ClassDescriptors of annotations applied directly to this method
-
getAnnotation
public AnnotationValue getAnnotation(ClassDescriptor desc)
Description copied from interface:XMethodGet the AnnotationValue of annotation applied directly to the method.- Specified by:
getAnnotationin interfaceAnnotatedObject- Specified by:
getAnnotationin 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:XMethodGet collection of all AnnotationValues applied directly to the method.- Specified by:
getAnnotationsin interfaceAnnotatedObject- Specified by:
getAnnotationsin 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:
addAnnotationin interfaceXMethod- Parameters:
annotationValue- an AnnotationValue representing a method annotation
-
addParameterAnnotation
public void addParameterAnnotation(int param, AnnotationValue annotationValue)Destructively add a parameter annotation.- Specified by:
addParameterAnnotationin interfaceXMethod- Parameters:
param- parameter (0 == first parameter)annotationValue- an AnnotationValue representing a parameter annotation
-
getMethodDescriptor
public MethodDescriptor getMethodDescriptor()
- Specified by:
getMethodDescriptorin interfaceXMethod- Returns:
- the MethodDescriptor identifying this object
-
getElementType
public java.lang.annotation.ElementType getElementType()
- Specified by:
getElementTypein interfaceAnnotatedObject
-
getContainingScope
@CheckForNull public AnnotatedObject getContainingScope()
- Specified by:
getContainingScopein interfaceAnnotatedObject
-
isVarArgs
public boolean isVarArgs()
-
usesConcurrency
public boolean usesConcurrency()
- Specified by:
usesConcurrencyin 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:
getAccessMethodForMethodin interfaceXMethod
-
getAccessMethodForField
@CheckForNull public FieldDescriptor getAccessMethodForField()
- Specified by:
getAccessMethodForFieldin interfaceXMethod
-
bridgeFrom
public XMethod bridgeFrom()
- Specified by:
bridgeFromin interfaceXMethod
-
bridgeTo
public XMethod bridgeTo()
Description copied from interface:XMethodIf 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:
resolveAccessMethodForMethodin interfaceXMethod
-
hasPolymorphicSignature
public boolean hasPolymorphicSignature()
Description copied from interface:XMethodSeejava.lang.invoke.MethodHandle.PolymorphicSignature- Specified by:
hasPolymorphicSignaturein interfaceXMethod- Returns:
- is this method polymorphic as defined in
MethodHandle
-
withSignature
public MethodInfo withSignature(java.lang.String otherMethodSignature)
- Parameters:
otherMethodSignature- A method signature, for instance ()Ljava/lang/Object;- Returns:
- a new
MethodInfowith the given signature
-
-