Class AnalysisScope
java.lang.Object
com.ibm.wala.ipa.callgraph.AnalysisScope
- Direct Known Subclasses:
CAstAnalysisScope, HybridAnalysisScope, JavaSourceAnalysisScope
Base class that represents a set of files to analyze.
The analysis scope is partitioned by class loader. There are three pre-defined class loader scopes:
- Primordial (for
rt.jar, the core classes) - Extension (for extension libraries in $JRE/lib/ext)
- Application (for the classes of the application)
Module.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Atomstatic final Atomfinal LinkedHashMap<Atom, ClassLoaderReference> static final Atomstatic final Atom -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddClassFileToScope(ClassLoaderReference loader, File file) Add a class file to the scope for a loadervoidaddInputStreamForJarToScope(ClassLoaderReference loader, InputStream stream) Add a jar file to the scope via anInputStream.voidaddJDKModuleToScope(String moduleName) Adds a module from the Java standard library to the analysis scope.voidaddSourceFileToScope(ClassLoaderReference loader, File file, String fileName) Add a class file to the scope for a loadervoidaddToScope(AnalysisScope other) Add all modules from another scopevoidaddToScope(ClassLoaderReference loader, Module m) Add a module to the scope for a loadervoidaddToScope(ClassLoaderReference loader, JarFile file) Add a jar file to the scope for a loadervoidaddToScopeHead(ClassLoaderReference loader, Module m) Add a module file to the scope for a loader.protected ClassLoaderReferenceclassLoaderName2Ref(String clName) static AnalysisScopeCreate an analysis scope initialized for analysis of JavafindMethod(Atom loader, String klass, Atom name, ImmutableByteArray desc) Utility function.Return the information regarding the application loader.protected ObjectReturn the information regarding the extension loader.getLanguage(Atom name) getModules(ClassLoaderReference loader) intReturn the information regarding the primordial loader.Return the information regarding the application loader.protected voidInitialize the standard 3 class loaders for java analysisprotected voidInitialize a scope for java analysisprotected voidinitSynthetic(ClassLoaderReference parent) Create the class loader for synthetic classes.booleanisApplicationLoader(IClassLoader loader) booleanbooleanbooleanbooleanbooleanvoidsetExclusions(SetOfClasses classes) Deprecated, for removal: This API element is subject to removal in a future version.voidsetExclusions(StringFilter classes) voidsetLoaderImpl(ClassLoaderReference ref, String implClass) toJson()An AnalysisScope is converted to a JSON formatted variable using the loaders and exclusions hierarchy using ToJson.Creates a "serializable" version of the analysis scope.toString()
-
Field Details
-
PRIMORDIAL
-
EXTENSION
-
APPLICATION
-
SYNTHETIC
-
loadersByName
-
-
Constructor Details
-
AnalysisScope
-
-
Method Details
-
createJavaAnalysisScope
Create an analysis scope initialized for analysis of Java -
initForJava
protected void initForJava()Initialize a scope for java analysis -
initCoreForJava
protected void initCoreForJava()Initialize the standard 3 class loaders for java analysis -
initSynthetic
Create the class loader for synthetic classes. -
getLanguage
-
isApplicationLoader
-
getPrimordialLoader
Return the information regarding the primordial loader. -
getExtensionLoader
Return the information regarding the extension loader. -
getApplicationLoader
Return the information regarding the application loader. -
getSyntheticLoader
Return the information regarding the application loader. -
getLanguages
- Returns:
- the set of languages to be processed during this analysis session.
-
getBaseLanguages
-
addSourceFileToScope
public void addSourceFileToScope(ClassLoaderReference loader, File file, String fileName) throws IllegalArgumentException Add a class file to the scope for a loader- Throws:
IllegalArgumentException
-
addClassFileToScope
public void addClassFileToScope(ClassLoaderReference loader, File file) throws IllegalArgumentException, InvalidClassFileException Add a class file to the scope for a loader -
addJDKModuleToScope
Adds a module from the Java standard library to the analysis scope.- Parameters:
moduleName- the name of the module, e.g.,"java.sql"- Throws:
IOException- if a module by that name cannot successfully be loaded
-
addInputStreamForJarToScope
public void addInputStreamForJarToScope(ClassLoaderReference loader, InputStream stream) throws IOException Add a jar file to the scope via anInputStream. NOTE: The InputStream should *not* be aJarInputStream; it should be a regularInputStreamfor the raw bytes of the jar file.- Throws:
IOException
-
addToScope
Add a jar file to the scope for a loader -
addToScope
Add a module to the scope for a loader -
addToScope
Add all modules from another scope -
addToScopeHead
Add a module file to the scope for a loader. The classes in the added jar file will override classes added to the scope so far. -
getLoader
- Returns:
- the ClassLoaderReference specified by
name. - Throws:
IllegalArgumentException- if name is null
-
classLoaderName2Ref
-
getLoaderImpl
-
setLoaderImpl
-
getLoaders
-
getNumberOfLoaders
public int getNumberOfLoaders() -
getExclusions
-
setExclusions
Deprecated, for removal: This API element is subject to removal in a future version.UsesetExclusions(StringFilter)} instead. -
setExclusions
-
toString
-
toJson
An AnalysisScope is converted to a JSON formatted variable using the loaders and exclusions hierarchy using ToJson. (Loaders) Primordial, Extension, Application, and Synthetic are the loaders keys; each one contains an arraylist of Strings. The exclusions contains an arraylist of strings.- Returns:
- json variable containing contents of the AnalysisScope
-
getExclusionString
- Returns:
- a String that describes exclusions from the analysis scope.
-
findMethod
Utility function. Useful when parsing input. -
getModules
-
getArrayClassLoader
- Returns:
- Returns the arrayClassLoader.
-
getJavaLibraryVersion
- Throws:
IllegalStateException
-
isJava18Libraries
- Throws:
IllegalStateException
-
isJava17Libraries
- Throws:
IllegalStateException
-
isJava16Libraries
- Throws:
IllegalStateException
-
isJava15Libraries
- Throws:
IllegalStateException
-
isJava14Libraries
- Throws:
IllegalStateException
-
toShallowAnalysisScope
Creates a "serializable" version of the analysis scope.- Returns:
- a "serializable" version of the analysis scope.
- Throws:
NotSerializableException
-
setExclusions(StringFilter)} instead.