Package edu.umd.cs.findbugs.detect
Class LazyInit
java.lang.Object
edu.umd.cs.findbugs.ByteCodePatternDetector
edu.umd.cs.findbugs.detect.LazyInit
- All Implemented Interfaces:
Detector
,Priorities
,StatelessDetector
,Cloneable
-
Field Summary
Fields inherited from interface edu.umd.cs.findbugs.Priorities
EXP_PRIORITY, HIGH_PRIORITY, IGNORE_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()
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
report, visitClassContext
-
Constructor Details
-
LazyInit
-
-
Method Details
-
clone
- Specified by:
clone
in interfaceStatelessDetector
- Overrides:
clone
in classObject
-
getBugReporter
- Specified by:
getBugReporter
in classByteCodePatternDetector
-
getPattern
Description copied from class:ByteCodePatternDetector
Get the ByteCodePattern for this detector.- Specified by:
getPattern
in classByteCodePatternDetector
-
prescreen
Description copied from class: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.
- Specified by:
prescreen
in classByteCodePatternDetector
- Parameters:
method
- the methodclassContext
- the ClassContext for the method- Returns:
- true if the method should be analyzed for instances of the ByteCodePattern
-
reportMatch
public void reportMatch(ClassContext classContext, org.apache.bcel.classfile.Method method, ByteCodePatternMatch match) throws CFGBuilderException, DataflowAnalysisException Description copied from class:ByteCodePatternDetector
Called to report an instance of the ByteCodePattern.- Specified by:
reportMatch
in classByteCodePatternDetector
- Parameters:
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- Throws:
CFGBuilderException
DataflowAnalysisException
-