public final class LazyInit extends ByteCodePatternDetector implements StatelessDetector
EXP_PRIORITY, HIGH_PRIORITY, IGNORE_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY
Constructor and Description |
---|
LazyInit(BugReporter bugReporter) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone() |
BugReporter |
getBugReporter() |
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.
|
report, visitClassContext
public LazyInit(BugReporter bugReporter)
public java.lang.Object clone()
clone
in interface StatelessDetector
clone
in class java.lang.Object
public BugReporter getBugReporter()
getBugReporter
in class ByteCodePatternDetector
public ByteCodePattern getPattern()
ByteCodePatternDetector
getPattern
in class ByteCodePatternDetector
public boolean prescreen(org.apache.bcel.classfile.Method method, ClassContext classContext)
ByteCodePatternDetector
Prescreen a method. It is a valid, but dumb, implementation simply to return true unconditionally. A better implementation is to call ClassContext.getBytecodeSet() to check whether the method actually contains the bytecode instructions that the pattern will look for. The theory is that checking the bytecode set is very fast, while building the MethodGen, CFG, ValueNumberAnalysis, etc. objects required to match ByteCodePatterns is slow, and the bytecode pattern matching algorithm is also not particularly fast.
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 methodpublic void reportMatch(ClassContext classContext, org.apache.bcel.classfile.Method method, ByteCodePatternMatch match) throws CFGBuilderException, DataflowAnalysisException
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 methodCFGBuilderException
DataflowAnalysisException
SpotBugs is licensed under the LGPL.