com.ibm.wala.ipa.callgraph
Class AnalysisScope

java.lang.Object
  extended by com.ibm.wala.ipa.callgraph.AnalysisScope
Direct Known Subclasses:
CAstAnalysisScope, J2EEAnalysisScope, JavaSourceAnalysisScope

public class AnalysisScope
extends java.lang.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:

Each class loader will load a set of classes described by a Module.


Field Summary
static Atom APPLICATION
           
static Atom EXTENSION
           
protected  java.util.LinkedHashMap<Atom,ClassLoaderReference> loadersByName
           
static Atom PRIMORDIAL
           
static Atom SYNTHETIC
           
 
Constructor Summary
protected AnalysisScope(java.util.Collection<? extends Language> languages)
           
 
Method Summary
 void addClassFileToScope(ClassLoaderReference loader, java.io.File file)
          Add a class file to the scope for a loader
 void addSourceFileToScope(ClassLoaderReference loader, java.io.File file, java.lang.String fileName)
          Add a class file to the scope for a loader
 void addToScope(AnalysisScope other)
          Add all modules from another scope
 void addToScope(ClassLoaderReference loader, java.util.jar.JarFile file)
          Add a jar file to the scope for a loader
 void addToScope(ClassLoaderReference loader, Module m)
          Add a module to the scope for a loader
 void addToScopeHead(ClassLoaderReference loader, Module m)
          Add a module file to the scope for a loader.
protected  ClassLoaderReference classLoaderName2Ref(java.lang.String clName)
           
static AnalysisScope createJavaAnalysisScope()
          Create an analysis scope initialized for analysis of Java
 MethodReference findMethod(Atom loader, java.lang.String klass, Atom name, ImmutableByteArray desc)
          Utility function.
 ClassLoaderReference getApplicationLoader()
          Return the information regarding the application loader.
 ArrayClassLoader getArrayClassLoader()
           
 java.util.Set<Language> getBaseLanguages()
           
 SetOfClasses getExclusions()
           
protected  java.lang.Object getExclusionString()
           
 ClassLoaderReference getExtensionLoader()
          Return the information regarding the extension loader.
 java.lang.String getJavaLibraryVersion()
           
 Language getLanguage(Atom name)
           
 java.util.Collection<Language> getLanguages()
           
 ClassLoaderReference getLoader(Atom name)
           
 java.lang.String getLoaderImpl(ClassLoaderReference ref)
           
 java.util.Collection<ClassLoaderReference> getLoaders()
           
 java.util.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 analysis
protected  void initForJava()
          Initialize a scope for java analysis
protected  void initSynthetic(ClassLoaderReference parent)
          Create the class loader for synthetic classes.
 boolean isApplicationLoader(IClassLoader loader)
           
 boolean isJava14Libraries()
           
 boolean isJava15Libraries()
           
 boolean isJava16Libraries()
           
 void setExclusions(SetOfClasses classes)
           
 void setLoaderImpl(ClassLoaderReference ref, java.lang.String implClass)
           
 ShallowAnalysisScope toShallowAnalysisScope()
          Creates a "serializable" version of the analysis scope.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 java.util.LinkedHashMap<Atom,ClassLoaderReference> loadersByName
Constructor Detail

AnalysisScope

protected AnalysisScope(java.util.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.


getLanguage

public Language getLanguage(Atom name)

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 java.util.Collection<Language> getLanguages()
Returns:
the set of languages to be processed during this analysis session.

getBaseLanguages

public java.util.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,
                                 java.io.File file,
                                 java.lang.String fileName)
                          throws java.lang.IllegalArgumentException
Add a class file to the scope for a loader

Throws:
java.lang.IllegalArgumentException

addClassFileToScope

public void addClassFileToScope(ClassLoaderReference loader,
                                java.io.File file)
                         throws java.lang.IllegalArgumentException
Add a class file to the scope for a loader

Throws:
java.lang.IllegalArgumentException

addToScope

public void addToScope(ClassLoaderReference loader,
                       java.util.jar.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 java.lang.IllegalArgumentException
Returns:
the ClassLoaderReference specified by name.
Throws:
java.lang.IllegalArgumentException - if name is null

classLoaderName2Ref

protected ClassLoaderReference classLoaderName2Ref(java.lang.String clName)

getLoaderImpl

public java.lang.String getLoaderImpl(ClassLoaderReference ref)

setLoaderImpl

public void setLoaderImpl(ClassLoaderReference ref,
                          java.lang.String implClass)

getLoaders

public java.util.Collection<ClassLoaderReference> getLoaders()

getNumberOfLoaders

public int getNumberOfLoaders()

getExclusions

public SetOfClasses getExclusions()

setExclusions

public void setExclusions(SetOfClasses classes)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getExclusionString

protected java.lang.Object getExclusionString()
Returns:
a String that describes exclusions from the analysis scope.

findMethod

public MethodReference findMethod(Atom loader,
                                  java.lang.String klass,
                                  Atom name,
                                  ImmutableByteArray desc)
Utility function. Useful when parsing input.


getModules

public java.util.List<Module> getModules(ClassLoaderReference loader)

getArrayClassLoader

public ArrayClassLoader getArrayClassLoader()
Returns:
Returns the arrayClassLoader.

getJavaLibraryVersion

public java.lang.String getJavaLibraryVersion()
                                       throws java.lang.IllegalStateException
Throws:
java.lang.IllegalStateException

isJava16Libraries

public boolean isJava16Libraries()
                          throws java.lang.IllegalStateException
Throws:
java.lang.IllegalStateException

isJava15Libraries

public boolean isJava15Libraries()
                          throws java.lang.IllegalStateException
Throws:
java.lang.IllegalStateException

isJava14Libraries

public boolean isJava14Libraries()
                          throws java.lang.IllegalStateException
Throws:
java.lang.IllegalStateException

toShallowAnalysisScope

public ShallowAnalysisScope toShallowAnalysisScope()
                                            throws java.io.NotSerializableException
Creates a "serializable" version of the analysis scope.

Returns:
a "serializable" version of the analysis scope.
Throws:
java.io.NotSerializableException