Package com.ibm.wala.classLoader
Class ClassLoaderImpl
- java.lang.Object
-
- com.ibm.wala.classLoader.ClassLoaderImpl
-
- All Implemented Interfaces:
IClassLoader
- Direct Known Subclasses:
WDexClassLoaderImpl
public class ClassLoaderImpl extends Object implements IClassLoader
A class loader that reads class definitions from a set of Modules.
-
-
Field Summary
Fields Modifier and Type Field Description protected IClassHierarchy
cha
Governing class hierarchystatic int
DEBUG_LEVEL
protected Map<TypeName,IClass>
loadedClasses
A mapping from class name (TypeName) to IClass
-
Constructor Summary
Constructors Constructor Description ClassLoaderImpl(ClassLoaderReference loader, ArrayClassLoader arrayClassLoader, IClassLoader parent, SetOfClasses exclusions, IClassHierarchy cha)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SSAInstructionFactory
getInstructionFactory()
Language
getLanguage()
Atom
getName()
int
getNumberOfClasses()
int
getNumberOfMethods()
IClassLoader
getParent()
Method getParent.ClassLoaderReference
getReference()
Return the ClassLoaderReference for this class loader.Reader
getSource(IClass klass)
Reader
getSource(IMethod method, int offset)
String
getSourceFileName(IClass klass)
String
getSourceFileName(IMethod method, int offset)
void
init(List<Module> modules)
Initialize internal data structuresIterator<IClass>
iterateAllClasses()
protected void
loadAllSources(Set<ModuleEntry> sourceModules)
Set up mapping from type name to Module EntryIClass
lookupClass(TypeName className)
Find and return the IClass defined by this class loader that corresponds to the given class name.void
removeAll(Collection<IClass> toRemove)
blow away references to any classes in the setString
toString()
-
-
-
Field Detail
-
DEBUG_LEVEL
public static final int DEBUG_LEVEL
- See Also:
- Constant Field Values
-
loadedClasses
protected final Map<TypeName,IClass> loadedClasses
A mapping from class name (TypeName) to IClass
-
cha
protected final IClassHierarchy cha
Governing class hierarchy
-
-
Constructor Detail
-
ClassLoaderImpl
public ClassLoaderImpl(ClassLoaderReference loader, ArrayClassLoader arrayClassLoader, IClassLoader parent, SetOfClasses exclusions, IClassHierarchy cha)
- Parameters:
loader
- class loader reference identifying this loaderparent
- parent loader for delegationexclusions
- set of classes to exclude from loading
-
-
Method Detail
-
loadAllSources
protected void loadAllSources(Set<ModuleEntry> sourceModules)
Set up mapping from type name to Module Entry
-
init
public void init(List<Module> modules) throws IOException
Initialize internal data structures- Specified by:
init
in interfaceIClassLoader
- Throws:
IllegalArgumentException
- if modules is nullIOException
-
getReference
public ClassLoaderReference getReference()
Description copied from interface:IClassLoader
Return the ClassLoaderReference for this class loader.- Specified by:
getReference
in interfaceIClassLoader
- Returns:
- ClassLoaderReference
-
iterateAllClasses
public Iterator<IClass> iterateAllClasses()
- Specified by:
iterateAllClasses
in interfaceIClassLoader
- Returns:
- an Iterator of all classes loaded by this loader
-
lookupClass
public IClass lookupClass(TypeName className)
Description copied from interface:IClassLoader
Find and return the IClass defined by this class loader that corresponds to the given class name.- Specified by:
lookupClass
in interfaceIClassLoader
- Parameters:
className
- name of the class- Returns:
- the IClass defined by this class loader that corresponds to the given class name, or null if not found.
-
getParent
public IClassLoader getParent()
Method getParent.- Specified by:
getParent
in interfaceIClassLoader
- Returns:
- the parent IClassLoader, if any, or null
-
getName
public Atom getName()
- Specified by:
getName
in interfaceIClassLoader
- Returns:
- the unique name that identifies this class loader.
-
getLanguage
public Language getLanguage()
- Specified by:
getLanguage
in interfaceIClassLoader
- Returns:
- the unique name that identifies the programming language from which this class loader loads code.
-
getNumberOfClasses
public int getNumberOfClasses()
- Specified by:
getNumberOfClasses
in interfaceIClassLoader
- Returns:
- the number of classes in scope to be loaded by this loader
-
getNumberOfMethods
public int getNumberOfMethods()
- Specified by:
getNumberOfMethods
in interfaceIClassLoader
-
getSourceFileName
public String getSourceFileName(IClass klass)
- Specified by:
getSourceFileName
in interfaceIClassLoader
- Parameters:
klass
- the class for which information is desired.- Returns:
- name of source file corresponding to the class, or null if not available
-
getSource
public Reader getSource(IMethod method, int offset)
- Specified by:
getSource
in interfaceIClassLoader
- Parameters:
method
- The method for which information is desiredoffset
- an offset into the bytecode of the given method.- Returns:
- input stream representing the source file for a given bytecode index of a given method, or null if not available
-
getSourceFileName
public String getSourceFileName(IMethod method, int offset)
- Specified by:
getSourceFileName
in interfaceIClassLoader
- Parameters:
method
- The method for which information is desiredoffset
- an offset into the bytecode of the given method.- Returns:
- name of the source file corresponding to the given offset in the given method. Note that this api allows a single method to arise from multiple source files, which is deliberate as it can happen in some languages.
-
getSource
public Reader getSource(IClass klass)
- Specified by:
getSource
in interfaceIClassLoader
- Returns:
- input stream representing the source file for a class, or null if not available
-
removeAll
public void removeAll(Collection<IClass> toRemove)
Description copied from interface:IClassLoader
blow away references to any classes in the set- Specified by:
removeAll
in interfaceIClassLoader
- Parameters:
toRemove
- Collection
-
getInstructionFactory
public SSAInstructionFactory getInstructionFactory()
- Specified by:
getInstructionFactory
in interfaceIClassLoader
-
-