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 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 ClassesModifier and TypeClassDescription(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClassDescriptor
private final ClassDescriptor
private final ObligationPolicyDatabase
private static final boolean
private final ClassDescriptor
private static final boolean
static final boolean
private final BugReporter
private boolean
Did we see any WillClose, WillNotClose, or WillCloseWhenClosed annotations in application code?private final ClassDescriptor
private final ClassDescriptor
private final ClassDescriptor
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 TypeMethodDescriptionprivate void
private void
addFileStreamEntries
(String kind) General method for adding entries for File InputStream/OutputStream/Reader/Writer classes.void
addObligations
(XMethod xmethod) private void
addParameterDeletesObligationDatabaseEntry
(XMethod xmethod, Obligation obligation, ObligationPolicyDatabaseEntryType entryType) Add an appropriate policy database entry for parameters marked with the WillClose annotation.void
This method is called at the end of the analysis pass.private void
handleWillCloseWhenClosed
(XMethod xmethod, Obligation deletedObligation) Handle a method with a WillCloseWhenClosed parameter annotation.void
loadDatabase
(URL u) private void
void
visitClass
(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 Details
-
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
-
database
-
willClose
-
willNotClose
-
willCloseWhenClosed
-
cleanupObligation
-
createsObligation
-
dischargesObligation
-
sawAnnotationsInApplicationCode
private boolean sawAnnotationsInApplicationCodeDid we see any WillClose, WillNotClose, or WillCloseWhenClosed annotations in application code?
-
-
Constructor Details
-
BuildObligationPolicyDatabase
-
-
Method Details
-
loadDatabase
-
visitClass
Description copied from interface:Detector2
Visit a class.- Specified by:
visitClass
in interfaceDetector2
- Parameters:
classDescriptor
- descriptor naming the class to visit- Throws:
CheckedAnalysisException
- if an exception occurs during analysis
-
addObligations
- Parameters:
xmethod
-
-
finishPass
public void finishPass()Description copied from interface:Detector2
This method is called at the end of the analysis pass.- Specified by:
finishPass
in interfaceDetector2
-
addBuiltInPolicies
private void addBuiltInPolicies() -
addFileStreamEntries
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
Handle a method with a WillCloseWhenClosed parameter annotation. -
scanForResourceTypes
private void scanForResourceTypes()
-