com.futureshocked.classloader
Class DebuggerClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by com.futureshocked.classloader.DebuggerClassLoader

public class DebuggerClassLoader
extends java.lang.ClassLoader

ClassLoader that allows for easy debugging of classes.


Field Summary
protected  java.lang.ClassLoader cl
          The parent ClassLoader for this object - very important!
protected  ClassTransforms ct
          ClassTransforms object that contains all InterceptedMethod objects.
protected  boolean verbose
          true if debugging information should be printed.
 
Constructor Summary
DebuggerClassLoader(java.lang.ClassLoader cl)
          Simple constructor that makes an empty ClassTransforms and sets verbose to false.
DebuggerClassLoader(java.lang.ClassLoader cl, ClassTransforms ct, boolean verbose)
          Full constructor that allows all instance variables to be set.
 
Method Summary
private  java.lang.Class defineClass(java.lang.String name, boolean modify)
          Defines a class, after using DebuggerClassVisitor if appropriate.
 java.lang.Class<?> loadClass(java.lang.String name, boolean resolve)
          Loads the requested class if it's not currently loaded, or returns the already loaded instance if appropriate.
This method declaration is Java 1.5 specific...
private  java.lang.Class useSystemDefine(java.lang.String className, byte[] bytecode)
          A hack to use reflection to modify java system classes.

This is almost certainly a BAD IDEA, and should be used with caution.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, 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
 

Field Detail

cl

protected final java.lang.ClassLoader cl
The parent ClassLoader for this object - very important!


ct

protected ClassTransforms ct
ClassTransforms object that contains all InterceptedMethod objects.


verbose

protected boolean verbose
true if debugging information should be printed.

Constructor Detail

DebuggerClassLoader

public DebuggerClassLoader(java.lang.ClassLoader cl)
Simple constructor that makes an empty ClassTransforms and sets verbose to false.

Parameters:
cl - The parent ClassLoader for this object - do not set to null!

DebuggerClassLoader

public DebuggerClassLoader(java.lang.ClassLoader cl,
                           ClassTransforms ct,
                           boolean verbose)
Full constructor that allows all instance variables to be set.

Parameters:
cl - The parent ClassLoader for this object - do not set to null!
ct - ClassTransforms that holds all InterceptedMethod objects
verbose - true if debugging information should be displayed.
Method Detail

loadClass

public java.lang.Class<?> loadClass(java.lang.String name,
                                    boolean resolve)
                             throws java.lang.ClassNotFoundException
Loads the requested class if it's not currently loaded, or returns the already loaded instance if appropriate.
This method declaration is Java 1.5 specific...

Overrides:
loadClass in class java.lang.ClassLoader
Parameters:
name - The name of the class to be loaded.
resolve - ignored currently
Returns:
Class object representing requested class.
Throws:
java.lang.ClassNotFoundException

defineClass

private java.lang.Class defineClass(java.lang.String name,
                                    boolean modify)
                             throws java.lang.ClassNotFoundException
Defines a class, after using DebuggerClassVisitor if appropriate.

Parameters:
name - The name of the class to load and define.
modify - true if we are going to transform this class.
Returns:
Class object representing the loaded class.
Throws:
java.lang.ClassNotFoundException

useSystemDefine

private java.lang.Class useSystemDefine(java.lang.String className,
                                        byte[] bytecode)
A hack to use reflection to modify java system classes.

This is almost certainly a BAD IDEA, and should be used with caution. This is possibly Sun JVM specific, and might not even work on old versions of Sun's JVM.

Parameters:
className - Name of class to be loaded.
bytecode - The bytecode representing the class.
Returns:
Class object that represents the loaded class.