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 AtomAPPLICATIONstatic AtomEXTENSIONprotected LinkedHashMap<Atom,ClassLoaderReference>loadersByNamestatic AtomPRIMORDIALstatic AtomSYNTHETIC
-
Constructor Summary
Constructors Modifier Constructor Description protectedAnalysisScope(Collection<? extends Language> languages)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddClassFileToScope(ClassLoaderReference loader, File file)Add a class file to the scope for a loadervoidaddSourceFileToScope(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 AnalysisScopecreateJavaAnalysisScope()Create an analysis scope initialized for analysis of JavaMethodReferencefindMethod(Atom loader, String klass, Atom name, ImmutableByteArray desc)Utility function.ClassLoaderReferencegetApplicationLoader()Return the information regarding the application loader.ArrayClassLoadergetArrayClassLoader()Set<Language>getBaseLanguages()SetOfClassesgetExclusions()protected ObjectgetExclusionString()ClassLoaderReferencegetExtensionLoader()Return the information regarding the extension loader.StringgetJavaLibraryVersion()LanguagegetLanguage(Atom name)Collection<Language>getLanguages()ClassLoaderReferencegetLoader(Atom name)StringgetLoaderImpl(ClassLoaderReference ref)Collection<ClassLoaderReference>getLoaders()List<Module>getModules(ClassLoaderReference loader)intgetNumberOfLoaders()ClassLoaderReferencegetPrimordialLoader()Return the information regarding the primordial loader.ClassLoaderReferencegetSyntheticLoader()Return the information regarding the application loader.protected voidinitCoreForJava()Initialize the standard 3 class loaders for java analysisprotected voidinitForJava()Initialize a scope for java analysisprotected voidinitSynthetic(ClassLoaderReference parent)Create the class loader for synthetic classes.booleanisApplicationLoader(IClassLoader loader)booleanisJava14Libraries()booleanisJava15Libraries()booleanisJava16Libraries()booleanisJava17Libraries()booleanisJava18Libraries()voidsetExclusions(SetOfClasses classes)voidsetLoaderImpl(ClassLoaderReference ref, String implClass)ShallowAnalysisScopetoShallowAnalysisScope()Creates a "serializable" version of the analysis scope.StringtoString()
-
-
-
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
-
-