Package edu.umd.cs.findbugs.detect
Class FindUnsatisfiedObligation.MethodChecker
- java.lang.Object
-
- edu.umd.cs.findbugs.detect.FindUnsatisfiedObligation.MethodChecker
-
- Enclosing class:
- FindUnsatisfiedObligation
private class FindUnsatisfiedObligation.MethodChecker extends java.lang.Object
A helper class to check a single method for unsatisfied obligations. Avoids having to pass millions of parameters to each method (type dataflow, null value dataflow, etc.).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
FindUnsatisfiedObligation.MethodChecker.PostProcessingPathVisitor
Helper class to apply the false-positive suppression heuristics along a Path where an obligation leak might have occurred.
-
Field Summary
Fields Modifier and Type Field Description (package private) IAnalysisCache
analysisCache
(package private) CFG
cfg
(package private) org.apache.bcel.generic.ConstantPoolGen
cpg
(package private) ObligationDataflow
dataflow
(package private) MethodDescriptor
methodDescriptor
(package private) Subtypes2
subtypes2
(package private) TypeDataflow
typeDataflow
(package private) XMethod
xmethod
-
Constructor Summary
Constructors Constructor Description MethodChecker(MethodDescriptor methodDescriptor, CFG cfg)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
analyzeMethod()
private void
annotateWarningWithSourceLineInformation(State state, Obligation obligation, BugInstance bugInstance)
private void
checkStateForLeakedObligations(State state, java.util.Map<Obligation,State> leakedObligationMap)
private int
getAdjustedLeakCount(State state, int obligationId)
Get the adjusted leak count for the given State and obligation type.private boolean
isPossibleInstanceOfObligationType(Subtypes2 subtypes2, org.apache.bcel.generic.ObjectType type, org.apache.bcel.generic.ObjectType obligationType)
private void
reportPath(BugInstance bugInstance, Obligation obligation, State state)
private void
reportWarning(Obligation obligation, State state, StateSet factAtExit)
-
-
-
Field Detail
-
methodDescriptor
MethodDescriptor methodDescriptor
-
cfg
CFG cfg
-
analysisCache
IAnalysisCache analysisCache
-
dataflow
ObligationDataflow dataflow
-
cpg
org.apache.bcel.generic.ConstantPoolGen cpg
-
typeDataflow
TypeDataflow typeDataflow
-
subtypes2
Subtypes2 subtypes2
-
xmethod
XMethod xmethod
-
-
Constructor Detail
-
MethodChecker
MethodChecker(MethodDescriptor methodDescriptor, CFG cfg)
-
-
Method Detail
-
analyzeMethod
public void analyzeMethod() throws CheckedAnalysisException
- Throws:
CheckedAnalysisException
-
checkStateForLeakedObligations
private void checkStateForLeakedObligations(State state, java.util.Map<Obligation,State> leakedObligationMap) throws java.lang.IllegalStateException
- Throws:
java.lang.IllegalStateException
-
reportWarning
private void reportWarning(Obligation obligation, State state, StateSet factAtExit)
-
annotateWarningWithSourceLineInformation
private void annotateWarningWithSourceLineInformation(State state, Obligation obligation, BugInstance bugInstance)
-
getAdjustedLeakCount
private int getAdjustedLeakCount(State state, int obligationId)
Get the adjusted leak count for the given State and obligation type. Use heuristics to account for:- null checks (count the number of times the supposedly leaked obligation is compared to null, and subtract those from the leak count)
- field assignments (count number of times obligation type is assigned to a field, and subtract those from the leak count)
- return statements (if an instance of the obligation type is returned from the method, subtract one from leak count)
- Returns:
- the adjusted leak count (positive if leaked obligation, negative if attempt to release an un-acquired obligation)
-
isPossibleInstanceOfObligationType
private boolean isPossibleInstanceOfObligationType(Subtypes2 subtypes2, org.apache.bcel.generic.ObjectType type, org.apache.bcel.generic.ObjectType obligationType) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
reportPath
private void reportPath(BugInstance bugInstance, Obligation obligation, State state)
-
-