Package edu.umd.cs.findbugs.detect
Class BuildObligationPolicyDatabase
- java.lang.Object
-
- edu.umd.cs.findbugs.detect.BuildObligationPolicyDatabase
-
- All Implemented Interfaces:
Detector2,FirstPassDetector,NonReportingDetector,Priorities
public class BuildObligationPolicyDatabase extends java.lang.Object implements Detector2, NonReportingDetector
Build the ObligationPolicyDatabase used by ObligationAnalysis. We preload the database with some known resources types needing to be released, and augment the database with additional entries discovered through scanning referenced classes for annotations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classBuildObligationPolicyDatabase.AuxiliaryObligationPropertyDatabase
-
Field Summary
Fields Modifier and Type Field Description private ClassDescriptorcleanupObligationprivate ClassDescriptorcreatesObligationprivate ObligationPolicyDatabasedatabaseprivate static booleanDEBUG_ANNOTATIONSprivate ClassDescriptordischargesObligationprivate static booleanDUMP_DBstatic booleanINFER_CLOSE_METHODSprivate BugReporterreporterprivate booleansawAnnotationsInApplicationCodeDid we see any WillClose, WillNotClose, or WillCloseWhenClosed annotations in application code?private ClassDescriptorwillCloseprivate ClassDescriptorwillCloseWhenClosedprivate ClassDescriptorwillNotClose-
Fields inherited from interface edu.umd.cs.findbugs.Priorities
EXP_PRIORITY, HIGH_PRIORITY, IGNORE_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description BuildObligationPolicyDatabase(BugReporter bugReporter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddBuiltInPolicies()private voidaddFileStreamEntries(java.lang.String kind)General method for adding entries for File InputStream/OutputStream/Reader/Writer classes.voidaddObligations(XMethod xmethod)private voidaddParameterDeletesObligationDatabaseEntry(XMethod xmethod, Obligation obligation, ObligationPolicyDatabaseEntryType entryType)Add an appropriate policy database entry for parameters marked with the WillClose annotation.voidfinishPass()This method is called at the end of the analysis pass.private voidhandleWillCloseWhenClosed(XMethod xmethod, Obligation deletedObligation)Handle a method with a WillCloseWhenClosed parameter annotation.voidloadDatabase(java.net.URL u)private voidscanForResourceTypes()voidvisitClass(ClassDescriptor classDescriptor)Visit a class.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.umd.cs.findbugs.Detector2
getDetectorClassName
-
-
-
-
Field Detail
-
INFER_CLOSE_METHODS
public static final boolean INFER_CLOSE_METHODS
-
DEBUG_ANNOTATIONS
private static final boolean DEBUG_ANNOTATIONS
-
DUMP_DB
private static final boolean DUMP_DB
-
reporter
private final BugReporter reporter
-
database
private final ObligationPolicyDatabase database
-
willClose
private final ClassDescriptor willClose
-
willNotClose
private final ClassDescriptor willNotClose
-
willCloseWhenClosed
private final ClassDescriptor willCloseWhenClosed
-
cleanupObligation
private final ClassDescriptor cleanupObligation
-
createsObligation
private final ClassDescriptor createsObligation
-
dischargesObligation
private final ClassDescriptor dischargesObligation
-
sawAnnotationsInApplicationCode
private boolean sawAnnotationsInApplicationCode
Did we see any WillClose, WillNotClose, or WillCloseWhenClosed annotations in application code?
-
-
Constructor Detail
-
BuildObligationPolicyDatabase
public BuildObligationPolicyDatabase(BugReporter bugReporter)
-
-
Method Detail
-
loadDatabase
public void loadDatabase(java.net.URL u)
-
visitClass
public void visitClass(ClassDescriptor classDescriptor) throws CheckedAnalysisException
Description copied from interface:Detector2Visit a class.- Specified by:
visitClassin interfaceDetector2- Parameters:
classDescriptor- descriptor naming the class to visit- Throws:
CheckedAnalysisException- if an exception occurs during analysis
-
addObligations
public void addObligations(XMethod xmethod)
- Parameters:
xmethod-
-
finishPass
public void finishPass()
Description copied from interface:Detector2This method is called at the end of the analysis pass.- Specified by:
finishPassin interfaceDetector2
-
addBuiltInPolicies
private void addBuiltInPolicies()
-
addFileStreamEntries
private void addFileStreamEntries(java.lang.String kind)
General method for adding entries for File InputStream/OutputStream/Reader/Writer classes.
-
addParameterDeletesObligationDatabaseEntry
private void addParameterDeletesObligationDatabaseEntry(XMethod xmethod, Obligation obligation, ObligationPolicyDatabaseEntryType entryType)
Add an appropriate policy database entry for parameters marked with the WillClose annotation.- Parameters:
xmethod- a methodobligation- the Obligation deleted by the methodentryType- type of entry (STRONG or WEAK)
-
handleWillCloseWhenClosed
private void handleWillCloseWhenClosed(XMethod xmethod, Obligation deletedObligation)
Handle a method with a WillCloseWhenClosed parameter annotation.
-
scanForResourceTypes
private void scanForResourceTypes()
-
-