org.ocltf.translation
Class TraceTranslator.TranslatorClassPool

java.lang.Object
  extended byjavassist.ClassPool
      extended byorg.ocltf.translation.TraceTranslator.TranslatorClassPool
Enclosing class:
TraceTranslator

protected static class TraceTranslator.TranslatorClassPool
extends javassist.ClassPool

Extends the Javaassist class pool so that we can define our own ClassLoader to use from which to find, load and modify and existing class.

Author:
Chad Brandon

Field Summary
 
Fields inherited from class javassist.ClassPool
classes, source, translator
 
Constructor Summary
protected TraceTranslator.TranslatorClassPool()
           
 
Method Summary
protected static javassist.ClassPool getPool(java.lang.ClassLoader loader)
          Retrieves an instance of this TranslatorClassPool using the loader to find/load any classes.
 java.lang.Class writeAsClass(java.lang.String classname)
          Returns a java.lang.Class object.
 
Methods inherited from class javassist.ClassPool
appendClassPath, appendClassPath, appendPathList, appendSystemPath, debugWriteFile, debugWriteFile, forName, get, get, get0, getAndRename, getCached, getDefault, getDefault, getMethod, getTranslator, insertClassPath, insertClassPath, lookupCflow, makeClass, makeClass, makeClass, makeInterface, makeInterface, removeCached, removeClassPath, toString, write, write, writeFile, writeFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TraceTranslator.TranslatorClassPool

protected TraceTranslator.TranslatorClassPool()
Method Detail

getPool

protected static javassist.ClassPool getPool(java.lang.ClassLoader loader)
Retrieves an instance of this TranslatorClassPool using the loader to find/load any classes.

Parameters:
loader -
Returns:

writeAsClass

public java.lang.Class writeAsClass(java.lang.String classname)
                             throws javassist.NotFoundException,
                                    java.io.IOException,
                                    javassist.CannotCompileException
Returns a java.lang.Class object. It calls write() to obtain a class file and then loads the obtained class file into the JVM. The returned Class object represents the loaded class.

To load a class file, this method uses an internal class loader. Thus, that class file is not loaded by the system class loader, which should have loaded this AspectClassPool class. The internal class loader loads only the classes explicitly specified by this method writeAsClass(). The other classes are loaded by the parent class loader (the sytem class loader) by delegation. Thus, if a class X loaded by the internal class loader refers to a class Y, then the class Y is loaded by the parent class loader.

Parameters:
classname - a fully-qualified class name.
Returns:
Class the Class it writes.
Throws:
javassist.NotFoundException
java.io.IOException
javassist.CannotCompileException


Copyright © 2003-2004 Chad Brandon. All Rights Reserved.