public class AltClassLoader
extends java.lang.ClassLoader
A ClassLoader
that loads specified classes from a
different class path than that given by the value of
java.class.path
in System.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 and Description |
---|
AltClassLoader(Singletons.Global g)
Constructs an
AltClassLoader for inclusion in Soot's
global variable manager, G . |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Class<?> |
findClass(java.lang.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.
|
java.lang.Class<?> |
loadClass(java.lang.String name)
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. |
static void |
main(java.lang.String[] argv)
A main() entry for basic unit testing.
|
void |
setAltClasses(java.lang.String[] classNames)
Specifies the set of class names that the
AltClassLoader
should load from the alternate classpath instead of the
regular classpath. |
void |
setAltClassPath(java.lang.String altClassPath)
Sets the list of locations in the alternate classpath.
|
static AltClassLoader |
v()
Returns the single instance of
AltClassLoader , which
loads classes from the classpath set by the most recent call to
its setAltClassPath(java.lang.String) . |
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
public AltClassLoader(Singletons.Global g)
AltClassLoader
for inclusion in Soot's
global variable manager, G
.g
- guarantees that the constructor may only be called from
Singletons
.public static AltClassLoader v()
AltClassLoader
, which
loads classes from the classpath set by the most recent call to
its setAltClassPath(java.lang.String)
.AltClassLoader
.public void setAltClassPath(java.lang.String altClassPath)
classPath
- A list of directories and jar files to
search for class files, delimited by
File.pathSeparator
.public void setAltClasses(java.lang.String[] classNames)
AltClassLoader
should load from the alternate classpath instead of the
regular classpath.classNames[]
- an array containing the names of classes to
be loaded from the AltClassLoader.protected java.lang.Class<?> findClass(java.lang.String maybeMangledName) throws java.lang.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.
findClass
in class java.lang.ClassLoader
maybeMangledName
- A string from which the desired class's
name can be determined. It may have been mangled by AltClassLoader.loadClass()
so
that the regular ClassLoader
to which we are
delegating won't load the class from the regular classpath.java.lang.ClassNotFoundException
- if the class cannot be loaded.public java.lang.Class<?> loadClass(java.lang.String name) throws java.lang.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.
loadClass
in class java.lang.ClassLoader
name
- the name of the class to load.java.lang.ClassNotFoundException
- if the class cannot be loaded.public static void main(java.lang.String[] argv) throws java.lang.ClassNotFoundException
A main() entry for basic unit testing.
Usage: path class ...
java.lang.ClassNotFoundException