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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addClassFileToScope
(ClassLoaderReference loader, File file) Add a class file to the scope for a loadervoid
addInputStreamForJarToScope
(ClassLoaderReference loader, InputStream stream) Add a jar file to the scope via anInputStream
.void
addJDKModuleToScope
(String moduleName) Adds a module from the Java standard library to the analysis scope.void
addSourceFileToScope
(ClassLoaderReference loader, File file, String fileName) Add a class file to the scope for a loadervoid
addToScope
(AnalysisScope other) Add all modules from another scopevoid
addToScope
(ClassLoaderReference loader, Module m) Add a module to the scope for a loadervoid
addToScope
(ClassLoaderReference loader, JarFile file) Add a jar file to the scope for a loadervoid
addToScopeHead
(ClassLoaderReference loader, Module m) Add a module file to the scope for a loader.protected ClassLoaderReference
classLoaderName2Ref
(String clName) static AnalysisScope
Create 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 Object
Return the information regarding the extension loader.getLanguage
(Atom name) getModules
(ClassLoaderReference loader) int
Return the information regarding the primordial loader.Return the information regarding the application loader.protected void
Initialize the standard 3 class loaders for java analysisprotected void
Initialize a scope for java analysisprotected void
initSynthetic
(ClassLoaderReference parent) Create the class loader for synthetic classes.boolean
isApplicationLoader
(IClassLoader loader) boolean
boolean
boolean
boolean
boolean
void
setExclusions
(SetOfClasses classes) void
setLoaderImpl
(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 regularInputStream
for 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
-
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
-