Package com.ibm.wala.ipa.summaries
Class BypassSyntheticClassLoader
- java.lang.Object
-
- com.ibm.wala.ipa.summaries.BypassSyntheticClassLoader
-
- All Implemented Interfaces:
IClassLoader
public class BypassSyntheticClassLoader extends Object implements IClassLoader
This class represents class loaders that introduce classes that do not exist in the actual application being analyzed. They may be abstract summaries of unanalyzed library code, wrappers that encode J2EE specialized behavior or other invented classes. The intention is that there be (at most) one such classloader in a given class hierarchy, and that it be referenced using the "Synthetic" classloader reference. Furthermore, it is required that this synthetic loader be a child loader of the Primordial, Extension and Application loaders. This special classloader has some interactions with the hierarchy for, while the classes it loads are normal-seeming IClass objects, unlike the other loaders, its set of classes is not fixed, causing special cases in code that caches hierarchy data. Also note that this causes the getNumberfClasses and iterateAllClasses methods to behave differently for those of other classloaders. Code that wants to introduce synthetic classes uses the registerClass method, giving it an Atom which is the class name, and an IClass which is the class to load. Since the synthetic loader musat be a child of the others, it would be very bad to use an existing name for a new synthetic class. Class lookup works just as for any other classloader.
-
-
Constructor Summary
Constructors Constructor Description BypassSyntheticClassLoader(ClassLoaderReference me, IClassLoader parent, SetOfClasses exclusions, IClassHierarchy cha)
Don't change my signature! ClassLoaderFactoryImpl calls me by reflection! yuck.
-
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()
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 structures.Iterator<IClass>
iterateAllClasses()
IClass
lookupClass(TypeName className)
Find and return the IClass defined by this class loader that corresponds to the given class name.void
registerClass(TypeName className, IClass theClass)
Register the existence of a new synthetic classvoid
removeAll(Collection<IClass> toRemove)
blow away references to any classes in the setString
toString()
-
-
-
Constructor Detail
-
BypassSyntheticClassLoader
public BypassSyntheticClassLoader(ClassLoaderReference me, IClassLoader parent, SetOfClasses exclusions, IClassHierarchy cha)
Don't change my signature! ClassLoaderFactoryImpl calls me by reflection! yuck.- Parameters:
me
- the name of this class loaderparent
- its parentexclusions
- classes to ignorecha
- governing class hierarchy
-
-
Method Detail
-
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.
-
registerClass
public void registerClass(TypeName className, IClass theClass)
Register the existence of a new synthetic class
-
getReference
public ClassLoaderReference getReference()
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
-
getNumberOfClasses
public int getNumberOfClasses()
- Specified by:
getNumberOfClasses
in interfaceIClassLoader
- Returns:
- the number of classes in scope to be loaded by this loader
-
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.
-
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
-
getParent
public IClassLoader getParent()
- Specified by:
getParent
in interfaceIClassLoader
- Returns:
- the parent IClassLoader, if any, or null
- See Also:
IClassLoader.getParent()
-
init
public void init(List<Module> modules) throws IOException
Description copied from interface:IClassLoader
Initialize internal data structures.- Specified by:
init
in interfaceIClassLoader
- Throws:
IOException
-
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
-
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
-
getInstructionFactory
public SSAInstructionFactory getInstructionFactory()
- Specified by:
getInstructionFactory
in interfaceIClassLoader
-
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.
-
-