Class AltClassLoader
- java.lang.Object
-
- java.lang.ClassLoader
-
- soot.util.cfgcmd.AltClassLoader
-
public class AltClassLoader extends ClassLoader
A
ClassLoaderthat loads specified classes from a different class path than that given by the value ofjava.class.pathinSystem.getProperties().This class is part of Soot's test infrastructure. It allows loading multiple implementations of a class with a given name, and was written to compare different implementations of Soot's CFG representations.
-
-
Constructor Summary
Constructors Constructor Description AltClassLoader(Singletons.Global g)Constructs anAltClassLoaderfor inclusion in Soot's global variable manager,G.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Class<?>findClass(String maybeMangledName)Loads a class from either the regular classpath, or the alternate classpath, depending on whether it looks like we have already mangled its name.Class<?>loadClass(String name)Loads a class, from the alternate classpath if the class's name has been included in the list of alternate classes withsetAltClasses(), from the regular system classpath otherwise.static voidmain(String[] argv)A main() entry for basic unit testing.voidsetAltClasses(String[] classNames)Specifies the set of class names that theAltClassLoadershould load from the alternate classpath instead of the regular classpath.voidsetAltClassPath(String altClassPath)Sets the list of locations in the alternate classpath.static AltClassLoaderv()Returns the single instance ofAltClassLoader, which loads classes from the classpath set by the most recent call to itssetAltClassPath(java.lang.String).-
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResource, findResources, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
-
-
-
Constructor Detail
-
AltClassLoader
public AltClassLoader(Singletons.Global g)
Constructs anAltClassLoaderfor inclusion in Soot's global variable manager,G.- Parameters:
g- guarantees that the constructor may only be called fromSingletons.
-
-
Method Detail
-
v
public static AltClassLoader v()
Returns the single instance ofAltClassLoader, which loads classes from the classpath set by the most recent call to itssetAltClassPath(java.lang.String).- Returns:
- Soot's
AltClassLoader.
-
setAltClassPath
public void setAltClassPath(String altClassPath)
Sets the list of locations in the alternate classpath.- Parameters:
altClassPath- A list of directories and jar files to search for class files, delimited byFile.pathSeparator.
-
setAltClasses
public void setAltClasses(String[] classNames)
Specifies the set of class names that theAltClassLoadershould load from the alternate classpath instead of the regular classpath.- Parameters:
classNames- [] an array containing the names of classes to be loaded from the AltClassLoader.
-
findClass
protected Class<?> findClass(String maybeMangledName) throws ClassNotFoundException
Loads a class from either the regular classpath, or the alternate classpath, depending on whether it looks like we have already mangled its name.
This method follows the steps provided by Ken McCrary's ClasssLoader tutorial.
- Overrides:
findClassin classClassLoader- Parameters:
maybeMangledName- A string from which the desired class's name can be determined. It may have been mangled byAltClassLoader.loadClass()so that the regularClassLoaderto which we are delegating won't load the class from the regular classpath.- Returns:
- the loaded class.
- Throws:
ClassNotFoundException- if the class cannot be loaded.
-
loadClass
public Class<?> loadClass(String name) throws ClassNotFoundException
Loads a class, from the alternate classpath if the class's name has been included in the list of alternate classes with
setAltClasses(), from the regular system classpath otherwise. When a alternate class is loaded, its references to other alternate classes are also resolved to the alternate classpath.- Overrides:
loadClassin classClassLoader- Parameters:
name- the name of the class to load.- Returns:
- the loaded class.
- Throws:
ClassNotFoundException- if the class cannot be loaded.
-
main
public static void main(String[] argv) throws ClassNotFoundException
A main() entry for basic unit testing.
Usage: path class ...
- Throws:
ClassNotFoundException
-
-