Class FindUnsatisfiedObligation.MethodChecker
java.lang.Object
edu.umd.cs.findbugs.detect.FindUnsatisfiedObligation.MethodChecker
- Enclosing class:
FindUnsatisfiedObligation
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 ClassesModifier and TypeClassDescriptionprivate classHelper class to apply the false-positive suppression heuristics along a Path where an obligation leak might have occurred. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) IAnalysisCache(package private) CFG(package private) org.apache.bcel.generic.ConstantPoolGen(package private) ObligationDataflow(package private) MethodDescriptor(package private) Subtypes2(package private) TypeDataflow(package private) XMethod -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprivate voidannotateWarningWithSourceLineInformation(State state, Obligation obligation, BugInstance bugInstance) private voidcheckStateForLeakedObligations(State state, Map<Obligation, State> leakedObligationMap) private intgetAdjustedLeakCount(State state, int obligationId) Get the adjusted leak count for the given State and obligation type.private booleanisPossibleInstanceOfObligationType(Subtypes2 subtypes2, org.apache.bcel.generic.ObjectType type, org.apache.bcel.generic.ObjectType obligationType) private voidreportPath(BugInstance bugInstance, Obligation obligation, State state) private voidreportWarning(Obligation obligation, State state, StateSet factAtExit)
-
Field Details
-
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 Details
-
MethodChecker
MethodChecker(MethodDescriptor methodDescriptor, CFG cfg)
-
-
Method Details
-
analyzeMethod
- Throws:
CheckedAnalysisException
-
checkStateForLeakedObligations
private void checkStateForLeakedObligations(State state, Map<Obligation, State> leakedObligationMap) throws IllegalStateException - Throws:
IllegalStateException
-
reportWarning
-
annotateWarningWithSourceLineInformation
private void annotateWarningWithSourceLineInformation(State state, Obligation obligation, BugInstance bugInstance) -
getAdjustedLeakCount
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 ClassNotFoundException - Throws:
ClassNotFoundException
-
reportPath
-