FindBugs™ 1.3.9

edu.umd.cs.findbugs.ba.bcp
Class Invoke

java.lang.Object
  extended by edu.umd.cs.findbugs.ba.bcp.PatternElement
      extended by edu.umd.cs.findbugs.ba.bcp.Invoke

public class Invoke
extends PatternElement

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:

  1. By an exact match. This is the default behavior.
  2. 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.
  3. 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:

  1. INSTANCE, which matches ordinary instance method invocations
  2. STATIC, which matches static method invocations
  3. 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.

Author:
David Hovemeyer
See Also:
PatternElement

Field Summary
static int ANY
          Match both static and instance invocations.
static int CONSTRUCTOR
          Match object constructor invocations.
static int INSTANCE
          Match ordinary (non-constructor) instance invocations.
static int ORDINARY_METHOD
          Match ordinary methods (everything except constructors).
static int STATIC
          Match static invocations.
 
Constructor Summary
Invoke(java.lang.String className, java.lang.String methodName, java.lang.String methodSig, int mode, RepositoryLookupFailureCallback lookupFailureCallback)
          Constructor.
 
Method Summary
 boolean acceptBranch(Edge edge, org.apache.bcel.generic.InstructionHandle source)
          Return whether or not it is acceptable to take the given branch.
 MatchResult match(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.
 int maxOccur()
          Return the maximum number of instructions this PatternElement must match in the ByteCodePattern.
 int minOccur()
          Return the minimum number of instructions this PatternElement must match in the ByteCodePattern.
 
Methods inherited from class edu.umd.cs.findbugs.ba.bcp.PatternElement
addOrCheckDefinition, allowTrailingEdges, dominatedBy, getDominatedBy, getLabel, getNext, label, lookup, setAllowTrailingEdges, setIndex, setNext, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INSTANCE

public static final int INSTANCE
Match ordinary (non-constructor) instance invocations.

See Also:
Constant Field Values

STATIC

public static final int STATIC
Match static invocations.

See Also:
Constant Field Values

CONSTRUCTOR

public static final int CONSTRUCTOR
Match object constructor invocations.

See Also:
Constant Field Values

ORDINARY_METHOD

public static final int ORDINARY_METHOD
Match ordinary methods (everything except constructors).

See Also:
Constant Field Values

ANY

public static final int ANY
Match both static and instance invocations.

See Also:
Constant Field Values
Constructor Detail

Invoke

public Invoke(java.lang.String className,
              java.lang.String methodName,
              java.lang.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 match
methodName - the name of the method; may be specified exactly or as a regexp
methodSig - the signature of the method; may be specified exactly or as a regexp
mode - the mode of invocation
Method Detail

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: PatternElement
Return whether or not this element matches the given instruction with the given Bindings in effect.

Specified by:
match in class PatternElement
Parameters:
handle - the instruction
cpg - the ConstantPoolGen from the method
before - the ValueNumberFrame representing values in the Java stack frame just before the execution of the instruction
after - the ValueNumberFrame representing values in the Java stack frame just after the execution of the instruction
bindingSet - 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

public boolean acceptBranch(Edge edge,
                            org.apache.bcel.generic.InstructionHandle source)
Description copied from class: PatternElement
Return whether or not it is acceptable to take the given branch.

Specified by:
acceptBranch in class PatternElement
Parameters:
edge - the Edge representing the branch
source - the source instruction of the branch
Returns:
true if the Edge is acceptable, false if not

minOccur

public int minOccur()
Description copied from class: PatternElement
Return the minimum number of instructions this PatternElement must match in the ByteCodePattern.

Specified by:
minOccur in class PatternElement

maxOccur

public int maxOccur()
Description copied from class: PatternElement
Return the maximum number of instructions this PatternElement must match in the ByteCodePattern.

Specified by:
maxOccur in class PatternElement

FindBugs™ 1.3.9

FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.