Closed KengoTODA closed 8 years ago
StaticConstant
is just a marker annotation. Currently FindBugs does not use this annotation for switching multi-threading strategy, it just use to detect defects. See CheckAnalysisContextContainedAnnotation
detector for detail, AnalysisContextContained
annotation is also used in this detector.
In other words, FindBugs detectors must not use static field to pass information across instances, so CheckAnalysisContextContainedAnnotation
detector will check our implementation to ensure its implementation follow this requirement. StaticConstant
and AnalysisContextContained
annotation are help us to tell our intent on each fields to this detector.
PropertyDatabase
is a property database for interprocedural analysis. By this class, we can map from method/field descriptor to property.
It also supports storing data to file. AnalysisContext
supports storing database onto file. To store, we need to call AnalysisContext#storePropertyDatabase()
. To load, we need AnalysisContext#loadPropertyDatabase()
or AnalysisContext#loadPropertyDatabaseFromResource()
.
// see TrainLongInstantfParams.java
@Override
public void report() {
AnalysisContext.currentAnalysisContext()
.storePropertyDatabase(database, "longInstant.db", "long instant database");
}
AnalysisContext
provides several methods which returns PropertyDatabase
(or AnnotationDatabase
etc.):
getCheckReturnAnnotationDatabase()
getDirectlyRelevantTypeQualifiersDatabase()
getFieldStoreTypeDatabase()
getJCIPAnnotationDatabase()
getNullnessAnnotationDatabase()
getReturnValueNullnessPropertyDatabase()
getUnconditionalDerefParamDatabase()