Package com.ibm.wala.ipa.callgraph
Class AnalysisScope
- java.lang.Object
-
- com.ibm.wala.ipa.callgraph.AnalysisScope
-
- Direct Known Subclasses:
CAstAnalysisScope
public class AnalysisScope extends Object
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
Fields Modifier and Type Field Description static Atom
APPLICATION
static Atom
EXTENSION
protected LinkedHashMap<Atom,ClassLoaderReference>
loadersByName
static Atom
PRIMORDIAL
static Atom
SYNTHETIC
-
Constructor Summary
Constructors Modifier Constructor Description protected
AnalysisScope(Collection<? extends Language> languages)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addClassFileToScope(ClassLoaderReference loader, File file)
Add a class file to the scope for a loadervoid
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
createJavaAnalysisScope()
Create an analysis scope initialized for analysis of JavaMethodReference
findMethod(Atom loader, String klass, Atom name, ImmutableByteArray desc)
Utility function.ClassLoaderReference
getApplicationLoader()
Return the information regarding the application loader.ArrayClassLoader
getArrayClassLoader()
Set<Language>
getBaseLanguages()
SetOfClasses
getExclusions()
protected Object
getExclusionString()
ClassLoaderReference
getExtensionLoader()
Return the information regarding the extension loader.String
getJavaLibraryVersion()
Language
getLanguage(Atom name)
Collection<Language>
getLanguages()
ClassLoaderReference
getLoader(Atom name)
String
getLoaderImpl(ClassLoaderReference ref)
Collection<ClassLoaderReference>
getLoaders()
List<Module>
getModules(ClassLoaderReference loader)
int
getNumberOfLoaders()
ClassLoaderReference
getPrimordialLoader()
Return the information regarding the primordial loader.ClassLoaderReference
getSyntheticLoader()
Return the information regarding the application loader.protected void
initCoreForJava()
Initialize the standard 3 class loaders for java analysisprotected void
initForJava()
Initialize a scope for java analysisprotected void
initSynthetic(ClassLoaderReference parent)
Create the class loader for synthetic classes.boolean
isApplicationLoader(IClassLoader loader)
boolean
isJava14Libraries()
boolean
isJava15Libraries()
boolean
isJava16Libraries()
boolean
isJava17Libraries()
boolean
isJava18Libraries()
void
setExclusions(SetOfClasses classes)
void
setLoaderImpl(ClassLoaderReference ref, String implClass)
ShallowAnalysisScope
toShallowAnalysisScope()
Creates a "serializable" version of the analysis scope.String
toString()
-
-
-
Field Detail
-
PRIMORDIAL
public static final Atom PRIMORDIAL
-
EXTENSION
public static final Atom EXTENSION
-
APPLICATION
public static final Atom APPLICATION
-
SYNTHETIC
public static final Atom SYNTHETIC
-
loadersByName
protected final LinkedHashMap<Atom,ClassLoaderReference> loadersByName
-
-
Constructor Detail
-
AnalysisScope
protected AnalysisScope(Collection<? extends Language> languages)
-
-
Method Detail
-
createJavaAnalysisScope
public static AnalysisScope 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
protected void initSynthetic(ClassLoaderReference parent)
Create the class loader for synthetic classes.
-
isApplicationLoader
public boolean isApplicationLoader(IClassLoader loader)
-
getPrimordialLoader
public ClassLoaderReference getPrimordialLoader()
Return the information regarding the primordial loader.
-
getExtensionLoader
public ClassLoaderReference getExtensionLoader()
Return the information regarding the extension loader.
-
getApplicationLoader
public ClassLoaderReference getApplicationLoader()
Return the information regarding the application loader.
-
getSyntheticLoader
public ClassLoaderReference getSyntheticLoader()
Return the information regarding the application loader.
-
getLanguages
public Collection<Language> getLanguages()
- Returns:
- the set of languages to be processed during this analysis session.
-
getBaseLanguages
public Set<Language> getBaseLanguages()
- Returns:
- the set of "base languages," each of which defines a family of compatible languages, and therefore induces a distinct ClassHierarchy
-
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
-
addToScope
public void addToScope(ClassLoaderReference loader, JarFile file)
Add a jar file to the scope for a loader
-
addToScope
public void addToScope(ClassLoaderReference loader, Module m)
Add a module to the scope for a loader
-
addToScope
public void addToScope(AnalysisScope other)
Add all modules from another scope
-
addToScopeHead
public void addToScopeHead(ClassLoaderReference loader, Module m)
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
public ClassLoaderReference getLoader(Atom name) throws IllegalArgumentException
- Returns:
- the ClassLoaderReference specified by
name
. - Throws:
IllegalArgumentException
- if name is null
-
classLoaderName2Ref
protected ClassLoaderReference classLoaderName2Ref(String clName)
-
getLoaderImpl
public String getLoaderImpl(ClassLoaderReference ref)
-
setLoaderImpl
public void setLoaderImpl(ClassLoaderReference ref, String implClass)
-
getLoaders
public Collection<ClassLoaderReference> getLoaders()
-
getNumberOfLoaders
public int getNumberOfLoaders()
-
getExclusions
public SetOfClasses getExclusions()
-
setExclusions
public void setExclusions(SetOfClasses classes)
-
getExclusionString
protected Object getExclusionString()
- Returns:
- a String that describes exclusions from the analysis scope.
-
findMethod
public MethodReference findMethod(Atom loader, String klass, Atom name, ImmutableByteArray desc)
Utility function. Useful when parsing input.
-
getModules
public List<Module> getModules(ClassLoaderReference loader)
-
getArrayClassLoader
public ArrayClassLoader getArrayClassLoader()
- Returns:
- Returns the arrayClassLoader.
-
getJavaLibraryVersion
public String getJavaLibraryVersion() throws IllegalStateException
- Throws:
IllegalStateException
-
isJava18Libraries
public boolean isJava18Libraries() throws IllegalStateException
- Throws:
IllegalStateException
-
isJava17Libraries
public boolean isJava17Libraries() throws IllegalStateException
- Throws:
IllegalStateException
-
isJava16Libraries
public boolean isJava16Libraries() throws IllegalStateException
- Throws:
IllegalStateException
-
isJava15Libraries
public boolean isJava15Libraries() throws IllegalStateException
- Throws:
IllegalStateException
-
isJava14Libraries
public boolean isJava14Libraries() throws IllegalStateException
- Throws:
IllegalStateException
-
toShallowAnalysisScope
public ShallowAnalysisScope toShallowAnalysisScope() throws NotSerializableException
Creates a "serializable" version of the analysis scope.- Returns:
- a "serializable" version of the analysis scope.
- Throws:
NotSerializableException
-
-