|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.umd.cs.findbugs.ByteCodePatternDetector
edu.umd.cs.findbugs.detect.BCPDoubleCheck
public class BCPDoubleCheck
A bug detector that uses a ByteCodePattern to find instances of the double check idiom. This class serves as a good example of how ByteCodePatterns can be used to simplify the task of implementing Detectors.
ByteCodePattern
Field Summary | |
---|---|
private BugReporter |
bugReporter
|
private static int |
CREATE_OBJ_WILD
Maximum number of "wildcard" instructions to accept for object creation in the doublecheck. |
private static int |
MAX_WILD
Default maximum number of "wildcard" instructions to accept between explicit pattern instructions. |
private static ByteCodePattern |
pattern
The doublecheck pattern. |
Fields inherited from interface edu.umd.cs.findbugs.Detector |
---|
EXP_PRIORITY, HIGH_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY |
Constructor Summary | |
---|---|
BCPDoubleCheck(BugReporter bugReporter)
Constructor. |
Method Summary | |
---|---|
ByteCodePattern |
getPattern()
Get the ByteCodePattern for this detector. |
boolean |
prescreen(org.apache.bcel.classfile.Method method,
ClassContext classContext)
Prescreen a method. |
void |
reportMatch(ClassContext classContext,
org.apache.bcel.classfile.Method method,
ByteCodePatternMatch match)
Called to report an instance of the ByteCodePattern. |
Methods inherited from class edu.umd.cs.findbugs.ByteCodePatternDetector |
---|
getAnalysisContext, report, setAnalysisContext, visitClassContext |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private BugReporter bugReporter
private static final int MAX_WILD
private static final int CREATE_OBJ_WILD
private static final ByteCodePattern pattern
Constructor Detail |
---|
public BCPDoubleCheck(BugReporter bugReporter)
bugReporter
- Method Detail |
---|
public ByteCodePattern getPattern()
ByteCodePatternDetector
getPattern
in class ByteCodePatternDetector
public boolean prescreen(org.apache.bcel.classfile.Method method, ClassContext classContext)
ByteCodePatternDetector
As a datapoint, prescreening speeds up the BCPDoubleCheck detector by a factor of 5 with no loss of generality and only a dozen or so extra lines of code.
prescreen
in class ByteCodePatternDetector
method
- the methodclassContext
- the ClassContext for the method
public void reportMatch(ClassContext classContext, org.apache.bcel.classfile.Method method, ByteCodePatternMatch match)
ByteCodePatternDetector
reportMatch
in class ByteCodePatternDetector
classContext
- the ClassContext for the analyzed classmethod
- the method to instance appears inmatch
- the ByteCodePatternMatch object representing the match
of the ByteCodePattern against actual instructions in the method
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |