Package edu.umd.cs.findbugs.classfile
Interface IAnalysisCache
-
- All Known Implementing Classes:
AnalysisCache
public interface IAnalysisCache
The analysis cache performs analyses on classes and methods and caches the results.- Author:
- David Hovemeyer
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description <E> void
eagerlyPutDatabase(java.lang.Class<E> databaseClass, E database)
Eagerly install a database.<E> void
eagerlyPutMethodAnalysis(java.lang.Class<E> analysisClass, MethodDescriptor methodDescriptor, E analysisObject)
Eagerly put a method analysis object in the cache.java.util.Map<?,?>
getAnalysisLocals()
Deprecated.This method is not necessary to realize multi-thread model in SpotBugs 4.0.<E> E
getClassAnalysis(java.lang.Class<E> analysisClass, ClassDescriptor classDescriptor)
Get an analysis of the given class.IClassPath
getClassPath()
Get the classpath from which classes are loaded.<E> E
getDatabase(java.lang.Class<E> databaseClass)
Get a database.IErrorLogger
getErrorLogger()
Get the error logger.<E> E
getMethodAnalysis(java.lang.Class<E> analysisClass, MethodDescriptor methodDescriptor)
Get an analysis of the given method.<E> E
getOptionalDatabase(java.lang.Class<E> databaseClass)
Profiler
getProfiler()
Get the analysis profiler instance, never null<E> E
probeClassAnalysis(java.lang.Class<E> analysisClass, ClassDescriptor classDescriptor)
See if the cache contains a cached class analysis result for given class descriptor.void
purgeAllMethodAnalysis()
Purge all method analysis results for all methods.void
purgeClassAnalysis(java.lang.Class<?> analysisClass)
Purge all class analysis results of a particular kindvoid
purgeMethodAnalyses(MethodDescriptor methodDescriptor)
Purge all analysis results for given method.<E> void
registerClassAnalysisEngine(java.lang.Class<E> analysisResultType, IClassAnalysisEngine<E> classAnalysisEngine)
Register the given class analysis engine as producing the analysis result type whose Class is given.<E> void
registerDatabaseFactory(java.lang.Class<E> databaseClass, IDatabaseFactory<E> databaseFactory)
Register a database factory.<E> void
registerMethodAnalysisEngine(java.lang.Class<E> analysisResultType, IMethodAnalysisEngine<E> methodAnalysisEngine)
Register the given method analysis engine as producing the analysis result type whose Class is given.
-
-
-
Method Detail
-
registerClassAnalysisEngine
<E> void registerClassAnalysisEngine(java.lang.Class<E> analysisResultType, IClassAnalysisEngine<E> classAnalysisEngine)
Register the given class analysis engine as producing the analysis result type whose Class is given.- Type Parameters:
E
- analysis result type- Parameters:
analysisResultType
- analysis result type Class objectclassAnalysisEngine
- the class analysis engine to register
-
registerMethodAnalysisEngine
<E> void registerMethodAnalysisEngine(java.lang.Class<E> analysisResultType, IMethodAnalysisEngine<E> methodAnalysisEngine)
Register the given method analysis engine as producing the analysis result type whose Class is given.- Type Parameters:
E
- analysis result type- Parameters:
analysisResultType
- analysis result type Class objectmethodAnalysisEngine
- the method analysis engine to register
-
getClassAnalysis
<E> E getClassAnalysis(java.lang.Class<E> analysisClass, @Nonnull ClassDescriptor classDescriptor) throws CheckedAnalysisException
Get an analysis of the given class.- Type Parameters:
E
- the type of the analysis (e.g., FoobarAnalysis)- Parameters:
analysisClass
- the analysis class object (e.g., FoobarAnalysis.class)classDescriptor
- the descriptor of the class to analyze- Returns:
- the analysis object (e.g., instance of FoobarAnalysis for the class)
- Throws:
CheckedAnalysisException
- if an error occurs performing the analysis
-
probeClassAnalysis
<E> E probeClassAnalysis(java.lang.Class<E> analysisClass, @Nonnull ClassDescriptor classDescriptor)
See if the cache contains a cached class analysis result for given class descriptor.- Parameters:
analysisClass
- analysis result classclassDescriptor
- the class descriptor- Returns:
- a cached analysis result, or null if there is no cached analysis result
-
getMethodAnalysis
<E> E getMethodAnalysis(java.lang.Class<E> analysisClass, @Nonnull MethodDescriptor methodDescriptor) throws CheckedAnalysisException
Get an analysis of the given method.- Type Parameters:
E
- the type of the analysis (e.g., FoobarAnalysis)- Parameters:
analysisClass
- the analysis class object (e.g., FoobarAnalysis.class)methodDescriptor
- the descriptor of the method to analyze- Returns:
- the analysis object (e.g., instance of FoobarAnalysis for the method)
- Throws:
CheckedAnalysisException
- if an error occurs performing the analysis
-
eagerlyPutMethodAnalysis
<E> void eagerlyPutMethodAnalysis(java.lang.Class<E> analysisClass, @Nonnull MethodDescriptor methodDescriptor, E analysisObject)
Eagerly put a method analysis object in the cache. This can be necessary if an method analysis engine invokes other analysis engines that might recursively require the analysis being produced.- Type Parameters:
E
- the type of the analysis (e.g., FoobarAnalysis)- Parameters:
analysisClass
- the analysis class object (e.g., FoobarAnalysis.class)methodDescriptor
- the descriptor of the method to analyzeanalysisObject
-
-
purgeMethodAnalyses
void purgeMethodAnalyses(@Nonnull MethodDescriptor methodDescriptor)
Purge all analysis results for given method. This can be called when a CFG is pruned and we want to compute more accurate analysis results on the new CFG.- Parameters:
methodDescriptor
- method whose analysis results should be purged
-
purgeAllMethodAnalysis
void purgeAllMethodAnalysis()
Purge all method analysis results for all methods.
-
purgeClassAnalysis
void purgeClassAnalysis(java.lang.Class<?> analysisClass)
Purge all class analysis results of a particular kind
-
registerDatabaseFactory
<E> void registerDatabaseFactory(java.lang.Class<E> databaseClass, IDatabaseFactory<E> databaseFactory)
Register a database factory.- Type Parameters:
E
- type of database- Parameters:
databaseClass
- Class of databasedatabaseFactory
- the database factory
-
getDatabase
<E> E getDatabase(java.lang.Class<E> databaseClass)
Get a database. Note: an unchecked analysis exception will be thrown if the database cannot be instantiated. Since instantiation of most kinds of databases simply involves creating an object (and not opening a file or other failure-prone operation), throwing a CheckedAnalysisException creates too great of an exception-handling burden on analyses and detectors which use databases.- Type Parameters:
E
- type of database- Parameters:
databaseClass
- Class of database- Returns:
- the database (which is created by a database factory if required)
-
getOptionalDatabase
@CheckForNull <E> E getOptionalDatabase(java.lang.Class<E> databaseClass)
-
eagerlyPutDatabase
<E> void eagerlyPutDatabase(java.lang.Class<E> databaseClass, E database)
Eagerly install a database. This avoids the need to register a database factory.- Type Parameters:
E
- type of database- Parameters:
databaseClass
- Class of databasedatabase
- database object
-
getClassPath
IClassPath getClassPath()
Get the classpath from which classes are loaded.- Returns:
- the classpath
-
getErrorLogger
IErrorLogger getErrorLogger()
Get the error logger.- Returns:
- the error logger
-
getAnalysisLocals
@Deprecated java.util.Map<?,?> getAnalysisLocals()
Deprecated.This method is not necessary to realize multi-thread model in SpotBugs 4.0. SeeAnalysisLocal
for detail.Get map of analysis-local objects.
-
getProfiler
Profiler getProfiler()
Get the analysis profiler instance, never null
-
-