Class Invoke
java.lang.Object
edu.umd.cs.findbugs.ba.bcp.PatternElement
edu.umd.cs.findbugs.ba.bcp.Invoke
A PatternElement to match a method invocation. Currently, we don't allow variables in this element (for arguments and return value). This would be a good thing to add. We also don't distinguish between invokevirtual, invokeinterface, and invokespecial.
Invoke objects match by class name, method name, method signature, and mode.
Names and signatures may be matched in several ways:
- By an exact match. This is the default behavior.
- By a regular expression. If the string provided to the Invoke constructor begins with a "/" character, the rest of the string is treated as a regular expression.
- As a subclass match. This only applies to class name matches. If the first character of a class name string is "+", then the rest of the string is treated as the name of a base class. Any subclass or subinterface of the named type will be accepted.
The mode specifies what kind of invocations in the Invoke element matches. It is specified as the bitwise combination of the following values:
-
INSTANCE, which matches ordinary instance method invocations -
STATIC, which matches static method invocations -
CONSTRUCTOR, which matches object constructor invocations
The special mode ORDINARY_METHOD is equivalent to
INSTANCE|STATIC. The special mode ANY is equivalent
to INSTANCE|STATIC|CONSTRUCTOR.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static classprivate static interfaceprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMatch both static and instance invocations.private final Invoke.StringMatcherstatic final intMatch object constructor invocations.static final intMatch ordinary (non-constructor) instance invocations.private final Invoke.StringMatcherprivate final Invoke.StringMatcherprivate final intstatic final intMatch ordinary methods (everything except constructors).static final intMatch static invocations. -
Constructor Summary
ConstructorsConstructorDescriptionInvoke(String className, String methodName, String methodSig, int mode, RepositoryLookupFailureCallback lookupFailureCallback) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptBranch(Edge edge, org.apache.bcel.generic.InstructionHandle source) Return whether or not it is acceptable to take the given branch.private Invoke.StringMatcherprivate Invoke.StringMatchermatch(org.apache.bcel.generic.InstructionHandle handle, org.apache.bcel.generic.ConstantPoolGen cpg, ValueNumberFrame before, ValueNumberFrame after, BindingSet bindingSet) Return whether or not this element matches the given instruction with the given Bindings in effect.intmaxOccur()Return the maximum number of instructions this PatternElement must match in the ByteCodePattern.intminOccur()Return the minimum number of instructions this PatternElement must match in the ByteCodePattern.Methods inherited from class PatternElement
addOrCheckDefinition, allowTrailingEdges, dominatedBy, getDominatedBy, getLabel, getNext, label, lookup, setAllowTrailingEdges, setIndex, setNext, toString
-
Field Details
-
INSTANCE
public static final int INSTANCEMatch ordinary (non-constructor) instance invocations.- See Also:
-
STATIC
public static final int STATICMatch static invocations.- See Also:
-
CONSTRUCTOR
public static final int CONSTRUCTORMatch object constructor invocations.- See Also:
-
ORDINARY_METHOD
public static final int ORDINARY_METHODMatch ordinary methods (everything except constructors).- See Also:
-
ANY
public static final int ANYMatch both static and instance invocations.- See Also:
-
classNameMatcher
-
methodNameMatcher
-
methodSigMatcher
-
mode
private final int mode
-
-
Constructor Details
-
Invoke
public Invoke(String className, String methodName, String methodSig, int mode, @Nullable RepositoryLookupFailureCallback lookupFailureCallback) Constructor.- Parameters:
className- the class name of the method; may be specified exactly, as a regexp, or as a subtype matchmethodName- the name of the method; may be specified exactly or as a regexpmethodSig- the signature of the method; may be specified exactly or as a regexpmode- the mode of invocation
-
-
Method Details
-
createClassMatcher
-
createMatcher
-
match
public MatchResult match(org.apache.bcel.generic.InstructionHandle handle, org.apache.bcel.generic.ConstantPoolGen cpg, ValueNumberFrame before, ValueNumberFrame after, BindingSet bindingSet) throws DataflowAnalysisException Description copied from class:PatternElementReturn whether or not this element matches the given instruction with the given Bindings in effect.- Specified by:
matchin classPatternElement- Parameters:
handle- the instructioncpg- the ConstantPoolGen from the methodbefore- the ValueNumberFrame representing values in the Java stack frame just before the execution of the instructionafter- the ValueNumberFrame representing values in the Java stack frame just after the execution of the instructionbindingSet- the set of Bindings- Returns:
- if the match is successful, returns a MatchResult with the PatternElement and BindingSet; if the match is not successful, returns null
- Throws:
DataflowAnalysisException
-
acceptBranch
Description copied from class:PatternElementReturn whether or not it is acceptable to take the given branch.- Specified by:
acceptBranchin classPatternElement- Parameters:
edge- the Edge representing the branchsource- the source instruction of the branch- Returns:
- true if the Edge is acceptable, false if not
-
minOccur
public int minOccur()Description copied from class:PatternElementReturn the minimum number of instructions this PatternElement must match in the ByteCodePattern.- Specified by:
minOccurin classPatternElement
-
maxOccur
public int maxOccur()Description copied from class:PatternElementReturn the maximum number of instructions this PatternElement must match in the ByteCodePattern.- Specified by:
maxOccurin classPatternElement
-