Class AnalysisCache
- java.lang.Object
-
- edu.umd.cs.findbugs.classfile.impl.AnalysisCache
-
- All Implemented Interfaces:
IAnalysisCache
public class AnalysisCache extends java.lang.Object implements IAnalysisCache
Implementation of IAnalysisCache. This object is responsible for registering class and method analysis engines and caching analysis results.- Author:
- David Hovemeyer
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <E> voideagerlyPutDatabase(java.lang.Class<E> databaseClass, E database)Eagerly install a database.<E> voideagerlyPutMethodAnalysis(java.lang.Class<E> analysisClass, MethodDescriptor methodDescriptor, java.lang.Object analysisObject)Eagerly put a method analysis object in the cache.java.util.Map<?,?>getAnalysisLocals()Get map of analysis-local objects.<E> EgetClassAnalysis(java.lang.Class<E> analysisClass, ClassDescriptor classDescriptor)Get an analysis of the given class.IClassPathgetClassPath()Get the classpath from which classes are loaded.<E> EgetDatabase(java.lang.Class<E> databaseClass)Get a database.IErrorLoggergetErrorLogger()Get the error logger.<E> EgetMethodAnalysis(java.lang.Class<E> analysisClass, MethodDescriptor methodDescriptor)Get an analysis of the given method.ProfilergetProfiler()Get the analysis profiler instance, never null<E> EprobeClassAnalysis(java.lang.Class<E> analysisClass, ClassDescriptor classDescriptor)See if the cache contains a cached class analysis result for given class descriptor.voidpurgeAllMethodAnalysis()Purge all analysis results for all methods.voidpurgeMethodAnalyses(MethodDescriptor methodDescriptor)Purge all analysis results for given method.<E> voidregisterClassAnalysisEngine(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> voidregisterDatabaseFactory(java.lang.Class<E> databaseClass, IDatabaseFactory<E> databaseFactory)Register a database factory.<E> voidregisterMethodAnalysisEngine(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
-
getAnalysisLocals
public final java.util.Map<?,?> getAnalysisLocals()
Description copied from interface:IAnalysisCacheGet map of analysis-local objects.- Specified by:
getAnalysisLocalsin interfaceIAnalysisCache
-
getClassPath
public IClassPath getClassPath()
Description copied from interface:IAnalysisCacheGet the classpath from which classes are loaded.- Specified by:
getClassPathin interfaceIAnalysisCache- Returns:
- the classpath
-
purgeAllMethodAnalysis
public void purgeAllMethodAnalysis()
Description copied from interface:IAnalysisCachePurge all analysis results for all methods.- Specified by:
purgeAllMethodAnalysisin interfaceIAnalysisCache
-
getClassAnalysis
public <E> E getClassAnalysis(java.lang.Class<E> analysisClass, ClassDescriptor classDescriptor) throws CheckedAnalysisExceptionDescription copied from interface:IAnalysisCacheGet an analysis of the given class.- Specified by:
getClassAnalysisin interfaceIAnalysisCache- 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
public <E> E probeClassAnalysis(java.lang.Class<E> analysisClass, ClassDescriptor classDescriptor)Description copied from interface:IAnalysisCacheSee if the cache contains a cached class analysis result for given class descriptor.- Specified by:
probeClassAnalysisin interfaceIAnalysisCache- Parameters:
analysisClass- analysis result classclassDescriptor- the class descriptor- Returns:
- a cached analysis result, or null if there is no cached analysis result
-
getMethodAnalysis
public <E> E getMethodAnalysis(java.lang.Class<E> analysisClass, MethodDescriptor methodDescriptor) throws CheckedAnalysisExceptionDescription copied from interface:IAnalysisCacheGet an analysis of the given method.- Specified by:
getMethodAnalysisin interfaceIAnalysisCache- 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
public <E> void eagerlyPutMethodAnalysis(java.lang.Class<E> analysisClass, MethodDescriptor methodDescriptor, java.lang.Object analysisObject)Description copied from interface:IAnalysisCacheEagerly 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.- Specified by:
eagerlyPutMethodAnalysisin interfaceIAnalysisCache- 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
-
purgeMethodAnalyses
public void purgeMethodAnalyses(MethodDescriptor methodDescriptor)
Description copied from interface:IAnalysisCachePurge 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.- Specified by:
purgeMethodAnalysesin interfaceIAnalysisCache- Parameters:
methodDescriptor- method whose analysis results should be purged
-
registerClassAnalysisEngine
public <E> void registerClassAnalysisEngine(java.lang.Class<E> analysisResultType, IClassAnalysisEngine<E> classAnalysisEngine)Description copied from interface:IAnalysisCacheRegister the given class analysis engine as producing the analysis result type whose Class is given.- Specified by:
registerClassAnalysisEnginein interfaceIAnalysisCache- Type Parameters:
E- analysis result type- Parameters:
analysisResultType- analysis result type Class objectclassAnalysisEngine- the class analysis engine to register
-
registerMethodAnalysisEngine
public <E> void registerMethodAnalysisEngine(java.lang.Class<E> analysisResultType, IMethodAnalysisEngine<E> methodAnalysisEngine)Description copied from interface:IAnalysisCacheRegister the given method analysis engine as producing the analysis result type whose Class is given.- Specified by:
registerMethodAnalysisEnginein interfaceIAnalysisCache- Type Parameters:
E- analysis result type- Parameters:
analysisResultType- analysis result type Class objectmethodAnalysisEngine- the method analysis engine to register
-
registerDatabaseFactory
public <E> void registerDatabaseFactory(java.lang.Class<E> databaseClass, IDatabaseFactory<E> databaseFactory)Description copied from interface:IAnalysisCacheRegister a database factory.- Specified by:
registerDatabaseFactoryin interfaceIAnalysisCache- Type Parameters:
E- type of database- Parameters:
databaseClass- Class of databasedatabaseFactory- the database factory
-
getDatabase
public <E> E getDatabase(java.lang.Class<E> databaseClass)
Description copied from interface:IAnalysisCacheGet 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.- Specified by:
getDatabasein interfaceIAnalysisCache- Type Parameters:
E- type of database- Parameters:
databaseClass- Class of database- Returns:
- the database (which is created by a database factory if required)
-
eagerlyPutDatabase
public <E> void eagerlyPutDatabase(java.lang.Class<E> databaseClass, E database)Description copied from interface:IAnalysisCacheEagerly install a database. This avoids the need to register a database factory.- Specified by:
eagerlyPutDatabasein interfaceIAnalysisCache- Type Parameters:
E- type of database- Parameters:
databaseClass- Class of databasedatabase- database object
-
getErrorLogger
public IErrorLogger getErrorLogger()
Description copied from interface:IAnalysisCacheGet the error logger.- Specified by:
getErrorLoggerin interfaceIAnalysisCache- Returns:
- the error logger
-
getProfiler
public Profiler getProfiler()
Description copied from interface:IAnalysisCacheGet the analysis profiler instance, never null- Specified by:
getProfilerin interfaceIAnalysisCache- Returns:
-
-