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.ObjectA 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 classFindUnsatisfiedObligation.MethodChecker.PostProcessingPathVisitorHelper 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) IAnalysisCacheanalysisCache(package private) CFGcfg(package private) org.apache.bcel.generic.ConstantPoolGencpg(package private) ObligationDataflowdataflow(package private) MethodDescriptormethodDescriptor(package private) Subtypes2subtypes2(package private) TypeDataflowtypeDataflow(package private) XMethodxmethod
-
Constructor Summary
Constructors Constructor Description MethodChecker(MethodDescriptor methodDescriptor, CFG cfg)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidanalyzeMethod()private voidannotateWarningWithSourceLineInformation(State state, Obligation obligation, BugInstance bugInstance)private voidcheckStateForLeakedObligations(State state, java.util.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 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)
-
-