Class PatternMatcher
java.lang.Object
edu.umd.cs.findbugs.ba.bcp.PatternMatcher
- All Implemented Interfaces:
DFSEdgeTypes, DFSEdgeTypes
Match a ByteCodePattern against the code of a method, represented by a CFG. Produces some number of ByteCodePatternMatch objects, which indicate how the pattern matched the bytecode instructions in the method.
This code is a hack and should probably be rewritten.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classObject representing the current state of the matching algorithm. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CFGprivate final org.apache.bcel.generic.ConstantPoolGen(package private) intMatch a sequence of pattern elements, starting at the given one.private final DepthFirstSearchprivate final DominatorsAnalysisprivate static final org.slf4j.Loggerprivate intprivate final ByteCodePatternprivate final LinkedList<ByteCodePatternMatch> private static final booleanprivate final IdentityHashMap<BasicBlock, BasicBlock> private final ValueNumberDataflowprivate final LinkedList<BasicBlock> Fields inherited from interface DFSEdgeTypes
BACK_EDGE, CROSS_EDGE, FORWARD_EDGE, TREE_EDGE, UNKNOWN_EDGE -
Constructor Summary
ConstructorsConstructorDescriptionPatternMatcher(ByteCodePattern pattern, ClassContext classContext, org.apache.bcel.classfile.Method method) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidattemptMatch(BasicBlock basicBlock, BasicBlock.InstructionIterator instructionIterator) Attempt to begin a match.Return an Iterator over the ByteCodePatternMatch objects representing successful matches of the ByteCodePattern.private voidexecute()Search for examples of the ByteCodePattern.private voidwork(PatternMatcher.State state)
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
SHOW_WILD
private static final boolean SHOW_WILD -
pattern
-
cfg
-
cpg
private final org.apache.bcel.generic.ConstantPoolGen cpg -
dfs
-
vnaDataflow
-
domAnalysis
-
workList
-
visitedBlockMap
-
resultList
-
nextPath
private int nextPath -
depth
int depthMatch a sequence of pattern elements, starting at the given one. The InstructionIterator should generally be positioned just before the next instruction to be matched. However, it may be positioned at the end of a basic block, in which case nothing will happen except that we will try to continue the match in the non-backedge successors of the basic block.
-
-
Constructor Details
-
PatternMatcher
public PatternMatcher(ByteCodePattern pattern, ClassContext classContext, org.apache.bcel.classfile.Method method) throws CFGBuilderException, DataflowAnalysisException Constructor.- Parameters:
pattern- the ByteCodePattern to look for examples ofclassContext- ClassContext for the class to analyzemethod- the Method to analyze- Throws:
CFGBuilderExceptionDataflowAnalysisException
-
-
Method Details
-
execute
Search for examples of the ByteCodePattern.- Returns:
- this object
- Throws:
DataflowAnalysisException- if the ValueNumberAnalysis did not produce useful values for the method
-
byteCodePatternMatchIterator
Return an Iterator over the ByteCodePatternMatch objects representing successful matches of the ByteCodePattern. -
attemptMatch
private void attemptMatch(BasicBlock basicBlock, BasicBlock.InstructionIterator instructionIterator) throws DataflowAnalysisException Attempt to begin a match.- Parameters:
basicBlock- the basic blockinstructionIterator- the instruction iterator positioned just before the first instruction to be matched- Throws:
DataflowAnalysisException
-
debug
-
work
- Throws:
DataflowAnalysisException
-