org.objectweb.jac.core
Class JacLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--org.objectweb.jac.core.JacLoader

public class JacLoader
extends ClassLoader

The JAC specific class loader for JAC objects.

This loader does the following things :

See Also:
WrappeeTranslator

Constructor Summary
JacLoader(boolean write, boolean clean)
          Create a JacLoader.
JacLoader(boolean write, boolean clean, ClassLoader otherClassLoader)
          Create a JacLoader.
 
Method Summary
protected  boolean analyzeClass(String classname)
          Tells wether a defered class's bytecode should be analyzed
static boolean classIsToBeAdapted(String name)
          Tell wether a class is to be adapted or not.
 boolean deferClass(String classname)
          Tells wether to defer loading of a class to the parent ClassLoader
static void displayClassInfo(String name)
          display some information about a class
Only use for debug purpose to verify that the class has been patched correctly.
 URL getResource(String name)
           
 InputStream getResourceAsStream(String name)
           
 boolean isLoaded(String classname)
          Returns true if the class is already loaded.
protected  Class loadClass(String class_name, boolean resolve)
           
static void main(String[] args)
          Usage: java org.objectweb.jac.core.JacLoader [class]
 void readProperties(Properties props)
          Use JacPropLoader to read some JAC properties
 void run(String classname, String[] args)
          Loads a class and calls main() in that class.
 void setWrappeeTranslator(WrappeeTranslator wt)
           
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, 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

JacLoader

public JacLoader(boolean write,
                 boolean clean,
                 ClassLoader otherClassLoader)
          throws Exception
Create a JacLoader.

Parameters:
write - if true, caches the tranlated classes on disk
clean - if true, clears the disk cache
otherClassLoader - if not null, indicates another ClassLoader where to search for classes not in original ClassPath

JacLoader

public JacLoader(boolean write,
                 boolean clean)
          throws Exception
Create a JacLoader. Same as JacLoader(boolean,boolean,null).

Parameters:
write - if true, caches the tranlated classes on disk
clean - if true, clears the disk cache
Method Detail

setWrappeeTranslator

public void setWrappeeTranslator(WrappeeTranslator wt)

deferClass

public boolean deferClass(String classname)
Tells wether to defer loading of a class to the parent ClassLoader

Parameters:
classname - name of the class
Returns:
true if we should defer the loading of that class

analyzeClass

protected boolean analyzeClass(String classname)
Tells wether a defered class's bytecode should be analyzed

Parameters:
classname - the name of the class

loadClass

protected Class loadClass(String class_name,
                          boolean resolve)
                   throws ClassNotFoundException
Overrides:
loadClass in class ClassLoader
ClassNotFoundException

getResourceAsStream

public InputStream getResourceAsStream(String name)
Overrides:
getResourceAsStream in class ClassLoader

getResource

public URL getResource(String name)
Overrides:
getResource in class ClassLoader

classIsToBeAdapted

public static boolean classIsToBeAdapted(String name)
Tell wether a class is to be adapted or not. All data are extracted from the jac.prop files located a various place.

Parameters:
name - a String value
Returns:
a boolean value (true if to be adpated).
See Also:
JacPropLoader, JacPropTools

displayClassInfo

public static void displayClassInfo(String name)
display some information about a class
Only use for debug purpose to verify that the class has been patched correctly.

Parameters:
name - the class to display
See Also:
ClassLoader

isLoaded

public boolean isLoaded(String classname)
Returns true if the class is already loaded.

Parameters:
classname - the class name to test
Returns:
true if already loaded

run

public void run(String classname,
                String[] args)
         throws Throwable
Loads a class and calls main() in that class.

This method was extracted "as is" from javassist 1.0 from Shigeru Chiba.

Javassist Homepage

Parameters:
classname - the loaded class.
args - parameters passed to main().
Throwable

readProperties

public void readProperties(Properties props)
Use JacPropLoader to read some JAC properties

Parameters:
props - the properties to read

main

public static void main(String[] args)
                 throws Exception
Usage: java org.objectweb.jac.core.JacLoader [class]

Exception