soot.util.cfgcmd
Class AltClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by soot.util.cfgcmd.AltClassLoader

public class AltClassLoader
extends 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 Summary
AltClassLoader(Singletons.Global g)
          Constructs an AltClassLoader for inclusion in Soot's global variable manager, G.
 
Method Summary
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 with setAltClasses(), from the regular system classpath otherwise.
static void main(String[] argv)
          A main() entry for basic unit testing.
 void setAltClasses(String[] classNames)
          Specifies the set of class names that the AltClassLoader should load from the alternate classpath instead of the regular classpath.
 void setAltClassPath(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).
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AltClassLoader

public AltClassLoader(Singletons.Global g)
Constructs an AltClassLoader for inclusion in Soot's global variable manager, G.

Parameters:
g - guarantees that the constructor may only be called from Singletons.
Method Detail

v

public 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).

Returns:
Soot's AltClassLoader.

setAltClassPath

public void setAltClassPath(String altClassPath)
Sets the list of locations in the alternate classpath.

Parameters:
classPath - A list of directories and jar files to search for class files, delimited by File.pathSeparator.

setAltClasses

public void setAltClasses(String[] classNames)
Specifies the set of class names that the AltClassLoader should 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:
findClass in class ClassLoader
Parameters:
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.
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:
loadClass in class ClassLoader
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