@NotThreadSafe
public class AnalysisContext
extends java.lang.Object
NOTE: this class is slated to become obsolete. New code should use the IAnalysisCache object returned by Global.getAnalysisCache() to access all analysis information (global databases, class and method analyses, etc.)
IAnalysisCache
,
Global
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG |
static java.lang.String |
DEFAULT_CHECK_FOR_NULL_PARAM_DATABASE_FILENAME |
static java.lang.String |
DEFAULT_NONNULL_PARAM_DATABASE_FILENAME |
static java.lang.String |
DEFAULT_NULL_RETURN_VALUE_ANNOTATION_DATABASE |
static java.lang.String |
DEFAULT_NULL_RETURN_VALUE_DB_FILENAME |
static boolean |
IGNORE_BUILTIN_MODELS |
protected RepositoryLookupFailureCallback |
lookupFailureCallback |
static java.lang.String |
NONNULL_RETURN_DB_FILENAME |
static java.lang.String |
NONNULL_RETURN_DB_RESOURCE |
static java.lang.String |
UNCONDITIONAL_DEREF_DB_FILENAME |
static java.lang.String |
UNCONDITIONAL_DEREF_DB_RESOURCE |
Constructor and Description |
---|
AnalysisContext(Project project) |
Modifier and Type | Method and Description |
---|---|
void |
addClasspathEntry(java.lang.String url)
Add an entry to the Repository's classpath.
|
void |
analysisSkippedDueToInvokeDynamic(XMethod m) |
static boolean |
analyzingApplicationClass() |
void |
clearClassBeingAnalyzed() |
void |
clearClassContextCache()
Clear the ClassContext cache.
|
void |
clearRepository()
Clear the BCEL Repository in preparation for analysis.
|
static AnalysisContext |
currentAnalysisContext()
Get the AnalysisContext associated with this thread
|
static XFactory |
currentXFactory() |
AnnotationRetentionDatabase |
getAnnotationRetentionDatabase() |
boolean |
getBoolProperty(int prop)
Get a boolean property.
|
XMethod |
getBridgeFrom(MethodInfo m) |
XMethod |
getBridgeTo(MethodInfo m) |
CheckReturnAnnotationDatabase |
getCheckReturnAnnotationDatabase() |
ClassDescriptor |
getClassBeingAnalyzed() |
ClassContext |
getClassContext(org.apache.bcel.classfile.JavaClass javaClass)
Get the ClassContext for a class.
|
java.lang.String |
getClassContextStats()
Get stats about hit rate for ClassContext cache.
|
int |
getClassSize(ClassDescriptor desc) |
ClassSummary |
getClassSummary() |
protected <E> E |
getDatabase(java.lang.Class<E> cls) |
java.lang.String |
getDatabaseInputDir()
Get the interprocedural database input directory.
|
java.lang.String |
getDatabaseOutputDir()
Get the interprocedural database output directory.
|
DirectlyRelevantTypeQualifiersDatabase |
getDirectlyRelevantTypeQualifiersDatabase() |
EqualsKindSummary |
getEqualsKindSummary() |
FieldStoreTypeDatabase |
getFieldStoreTypeDatabase()
Get the property database recording the types of values stored into
fields.
|
FieldSummary |
getFieldSummary() |
InnerClassAccessMap |
getInnerClassAccessMap() |
JCIPAnnotationDatabase |
getJCIPAnnotationDatabase() |
RepositoryLookupFailureCallback |
getLookupFailureCallback()
Get the lookup failure callback.
|
TypeQualifierNullnessAnnotationDatabase |
getNullnessAnnotationDatabase() |
ReturnValueNullnessPropertyDatabase |
getReturnValueNullnessPropertyDatabase()
Get the property database recording which methods always return nonnull
values
|
SourceFinder |
getSourceFinder()
Get the SourceFinder, for finding source files.
|
SourceInfoMap |
getSourceInfoMap()
Get the SourceInfoMap.
|
Subtypes2 |
getSubtypes2()
Get the Subtypes2 inheritance hierarchy database.
|
SuppressionMatcher |
getSuppressionMatcher() |
ParameterNullnessPropertyDatabase |
getUnconditionalDerefParamDatabase()
Get the property database recording which methods unconditionally
dereference parameters.
|
UnreadFields |
getUnreadFields() |
UnreadFieldsData |
getUnreadFieldsData() |
java.util.Collection<XClass> |
getXClassCollection()
Get Collection of all XClass objects seen so far.
|
void |
initDatabases()
Instantiate the CheckReturnAnnotationDatabase.
|
boolean |
isApplicationClass(ClassDescriptor desc) |
boolean |
isApplicationClass(org.apache.bcel.classfile.JavaClass cls)
Return whether or not the given class is an application class.
|
boolean |
isApplicationClass(java.lang.String className)
Return whether or not the given class is an application class.
|
boolean |
isTooBig(ClassDescriptor desc) |
void |
loadDefaultInterproceduralDatabases()
If possible, load default (built-in) interprocedural property databases.
|
void |
loadInterproceduralDatabases()
If possible, load interprocedural property databases.
|
<DatabaseType extends PropertyDatabase<KeyType,Property>,KeyType extends FieldOrMethodDescriptor,Property> |
loadPropertyDatabase(DatabaseType database,
java.lang.String fileName,
java.lang.String description)
Load an interprocedural property database.
|
<DatabaseType extends PropertyDatabase<KeyType,Property>,KeyType extends FieldOrMethodDescriptor,Property> |
loadPropertyDatabaseFromResource(DatabaseType database,
java.lang.String resourceName,
java.lang.String description)
Load an interprocedural property database.
|
void |
logAnError(java.lang.String msg) |
static void |
logError(java.lang.String msg)
Report an error
|
static void |
logError(java.lang.String msg,
java.lang.Exception e)
Report an error
|
org.apache.bcel.classfile.JavaClass |
lookupClass(ClassDescriptor classDescriptor)
Lookup a class.
|
org.apache.bcel.classfile.JavaClass |
lookupClass(java.lang.String className)
Lookup a class.
|
java.lang.String |
lookupSourceFile(java.lang.String dottedClassName)
Lookup a class's source file
|
static org.apache.bcel.classfile.JavaClass |
lookupSystemClass(java.lang.String className)
This is equivalent to Repository.lookupClass() or this.lookupClass(),
except it uses the original Repository instead of the current one.
|
static void |
removeCurrentAnalysisContext() |
static void |
reportMissingClass(ClassDescriptor c) |
static void |
reportMissingClass(java.lang.ClassNotFoundException e)
file a ClassNotFoundException with the lookupFailureCallback
|
static void |
reportMissingClass(MissingClassException e) |
static void |
reportMissingClass(MissingClassException e) |
void |
setAppClassList(java.util.List<ClassDescriptor> appClassCollection) |
void |
setBoolProperty(int prop,
boolean value)
Set a boolean property.
|
void |
setBridgeMethod(MethodInfo from,
MethodInfo to) |
void |
setClassBeingAnalyzed(ClassDescriptor classBeingAnalyzed) |
void |
setClassSummary(ClassSummary classSummary) |
static void |
setCurrentAnalysisContext(AnalysisContext analysisContext)
Set the current analysis context for this thread.
|
void |
setDatabaseInputDir(java.lang.String databaseInputDir)
Set the interprocedural database input directory.
|
void |
setDatabaseOutputDir(java.lang.String databaseOutputDir)
Set the interprocedural database output directory.
|
void |
setFieldSummary(FieldSummary fieldSummary) |
boolean |
setMissingClassWarningsSuppressed(boolean value) |
void |
setUnreadFields(UnreadFields unreadFields) |
<DatabaseType extends PropertyDatabase<KeyType,Property>,KeyType extends FieldOrMethodDescriptor,Property> |
storePropertyDatabase(DatabaseType database,
java.lang.String fileName,
java.lang.String description)
Write an interprocedural property database.
|
boolean |
unreadFieldsAvailable() |
void |
updateDatabases(int pass)
After a pass has been completed, allow the analysis context to update
information.
|
public static final boolean DEBUG
public static final boolean IGNORE_BUILTIN_MODELS
public static final java.lang.String DEFAULT_NONNULL_PARAM_DATABASE_FILENAME
public static final java.lang.String DEFAULT_CHECK_FOR_NULL_PARAM_DATABASE_FILENAME
public static final java.lang.String DEFAULT_NULL_RETURN_VALUE_ANNOTATION_DATABASE
public static final java.lang.String UNCONDITIONAL_DEREF_DB_FILENAME
public static final java.lang.String NONNULL_RETURN_DB_FILENAME
public static final java.lang.String UNCONDITIONAL_DEREF_DB_RESOURCE
public static final java.lang.String NONNULL_RETURN_DB_RESOURCE
public static final java.lang.String DEFAULT_NULL_RETURN_VALUE_DB_FILENAME
protected final RepositoryLookupFailureCallback lookupFailureCallback
public AnalysisContext(@Nonnull Project project)
public static AnalysisContext currentAnalysisContext()
public static XFactory currentXFactory()
public ClassDescriptor getClassBeingAnalyzed()
public void setClassBeingAnalyzed(@Nonnull ClassDescriptor classBeingAnalyzed)
public void clearClassBeingAnalyzed()
public ClassSummary getClassSummary()
public void setClassSummary(@Nonnull ClassSummary classSummary)
public EqualsKindSummary getEqualsKindSummary()
public FieldSummary getFieldSummary()
public void setFieldSummary(@Nonnull FieldSummary fieldSummary)
@Nonnull public UnreadFieldsData getUnreadFieldsData()
@Nonnull public UnreadFields getUnreadFields()
public boolean unreadFieldsAvailable()
public void setUnreadFields(@Nonnull UnreadFields unreadFields)
public static void reportMissingClass(java.lang.ClassNotFoundException e)
getLookupFailureCallback()
public static void reportMissingClass(MissingClassException e)
public static boolean analyzingApplicationClass()
public static void reportMissingClass(MissingClassException e)
public static void reportMissingClass(ClassDescriptor c)
public static void logError(java.lang.String msg, java.lang.Exception e)
public static void logError(java.lang.String msg)
public void logAnError(java.lang.String msg)
public void analysisSkippedDueToInvokeDynamic(XMethod m)
public boolean setMissingClassWarningsSuppressed(boolean value)
public boolean isApplicationClass(org.apache.bcel.classfile.JavaClass cls)
cls
- the class to lookuppublic boolean isApplicationClass(@DottedClassName java.lang.String className)
className
- name of a classpublic boolean isApplicationClass(ClassDescriptor desc)
public int getClassSize(ClassDescriptor desc)
public boolean isTooBig(ClassDescriptor desc)
public org.apache.bcel.classfile.JavaClass lookupClass(@Nonnull ClassDescriptor classDescriptor) throws java.lang.ClassNotFoundException
classDescriptor
- descriptor specifying the class to look upjava.lang.ClassNotFoundException
- if the class can't be foundpublic static org.apache.bcel.classfile.JavaClass lookupSystemClass(@Nonnull java.lang.String className) throws java.lang.ClassNotFoundException
className
- the name of the classjava.lang.ClassNotFoundException
public final java.lang.String lookupSourceFile(@Nonnull@DottedClassName java.lang.String dottedClassName)
dottedClassName
- the name of the classSourceLineAnnotation.UNKNOWN_SOURCE_FILE
if unable to
determinepublic final void loadInterproceduralDatabases()
public final void loadDefaultInterproceduralDatabases()
public final void setBoolProperty(@AnalysisFeatures.AnalysisFeature int prop, boolean value)
prop
- the property to setvalue
- the value of the propertypublic final boolean getBoolProperty(@AnalysisFeatures.AnalysisFeature int prop)
prop
- the propertypublic final void setDatabaseInputDir(java.lang.String databaseInputDir)
databaseInputDir
- the interprocedural database input directorypublic final java.lang.String getDatabaseInputDir()
public final void setDatabaseOutputDir(java.lang.String databaseOutputDir)
databaseOutputDir
- the interprocedural database output directorypublic final java.lang.String getDatabaseOutputDir()
public <DatabaseType extends PropertyDatabase<KeyType,Property>,KeyType extends FieldOrMethodDescriptor,Property> DatabaseType loadPropertyDatabase(DatabaseType database, java.lang.String fileName, java.lang.String description)
DatabaseType
- actual type of the databaseKeyType
- type of key (e.g., method or field)Property
- type of properties stored in the databasedatabase
- the empty database objectfileName
- file to load database fromdescription
- description of the database (for diagnostics)public <DatabaseType extends PropertyDatabase<KeyType,Property>,KeyType extends FieldOrMethodDescriptor,Property> DatabaseType loadPropertyDatabaseFromResource(DatabaseType database, java.lang.String resourceName, java.lang.String description)
DatabaseType
- actual type of the databaseKeyType
- type of key (e.g., method or field)Property
- type of properties stored in the databasedatabase
- the empty database objectresourceName
- name of resource to load the database fromdescription
- description of the database (for diagnostics)public <DatabaseType extends PropertyDatabase<KeyType,Property>,KeyType extends FieldOrMethodDescriptor,Property> void storePropertyDatabase(DatabaseType database, java.lang.String fileName, java.lang.String description)
DatabaseType
- actual type of the databaseKeyType
- type of key (e.g., method or field)Property
- type of properties stored in the databasedatabase
- the databasefileName
- name of database filedescription
- description of the databasepublic static void setCurrentAnalysisContext(AnalysisContext analysisContext)
analysisContext
- the current analysis context for this threadpublic static void removeCurrentAnalysisContext()
public java.util.Collection<XClass> getXClassCollection()
public SuppressionMatcher getSuppressionMatcher()
public void addClasspathEntry(java.lang.String url) throws java.io.IOException
url
- the classpath entry URLjava.io.IOException
public void clearClassContextCache()
public void clearRepository()
public AnnotationRetentionDatabase getAnnotationRetentionDatabase()
public CheckReturnAnnotationDatabase getCheckReturnAnnotationDatabase()
public ClassContext getClassContext(org.apache.bcel.classfile.JavaClass javaClass)
javaClass
- the classpublic java.lang.String getClassContextStats()
public FieldStoreTypeDatabase getFieldStoreTypeDatabase()
public JCIPAnnotationDatabase getJCIPAnnotationDatabase()
public RepositoryLookupFailureCallback getLookupFailureCallback()
public SourceFinder getSourceFinder()
public SourceInfoMap getSourceInfoMap()
public ParameterNullnessPropertyDatabase getUnconditionalDerefParamDatabase()
public void initDatabases()
public org.apache.bcel.classfile.JavaClass lookupClass(@Nonnull@DottedClassName java.lang.String className) throws java.lang.ClassNotFoundException
className
- the name of the classjava.lang.ClassNotFoundException
- (but not really)public InnerClassAccessMap getInnerClassAccessMap()
public void setAppClassList(java.util.List<ClassDescriptor> appClassCollection)
public void updateDatabases(int pass)
pass
- -- the first pass is pass 0public ReturnValueNullnessPropertyDatabase getReturnValueNullnessPropertyDatabase()
public Subtypes2 getSubtypes2()
public DirectlyRelevantTypeQualifiersDatabase getDirectlyRelevantTypeQualifiersDatabase()
@CheckForNull public XMethod getBridgeTo(MethodInfo m)
@CheckForNull public XMethod getBridgeFrom(MethodInfo m)
public void setBridgeMethod(MethodInfo from, MethodInfo to)
public TypeQualifierNullnessAnnotationDatabase getNullnessAnnotationDatabase()
protected <E> E getDatabase(java.lang.Class<E> cls)
FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.