Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.jxcl.cl
Class JXClassLoader  view JXClassLoader download JXClassLoader.java

java.lang.Object
  extended byjava.lang.ClassLoader
      extended byjava.security.SecureClassLoader
          extended byjava.net.URLClassLoader
              extended byorg.jxcl.cl.JXClassLoader

public class JXClassLoader
extends java.net.URLClassLoader

Transforming class loader. Can be directed to instrument a set of classes, matching class names against a list of prefixes and another list excluding classes from instrumentation, the exclusion list taking priority. Will delegate loading to a parent class loader where explicitly directed to; otherwise will be the defining loader. By default the loading of classes whose names begin with java., javax., junit., org.apache.bcel., org.apache.tools.ant. and org.jxcl. is delegated.

Classes whose names begin with a reserved prefix, currently test.data.Test, are synthesized instead of being loaded. This must be specifically enabled.


Nested Class Summary
 
Nested classes inherited from class java.net.URLClassLoader
 
Nested classes inherited from class java.lang.ClassLoader
 
Field Summary
private  java.util.List classPath
          URLs in the order in which they are to be searched.
static char CLASSPATH_DELIM_CHAR
           
static java.lang.String CLASSPATH_DELIM_STR
           
(package private)  java.util.List cxf
          Configurable class transformers.
private  java.util.List delegated
           
static java.lang.String[] DELEGATED
          Names of classes which must be loaded by the parent.
private  java.lang.String[] dels
          XXX This is misleading! What's wanted is a copy.
private  java.util.List excluded
          Names of classes NOT to be instrumented.
static char FILE_PATH_DELIM_CHAR
          Operating system specific
static java.lang.String FILE_PATH_DELIM_STR
           
(package private)  java.util.List gxf
          Configurable graph transformers.
private  java.util.List included
          Names of classes to be instrumented.
(package private)  java.util.List mxf
          Configurable method transformers.
private  java.lang.ClassLoader parent
          Delegation class loader.
(package private)  java.util.List regList
          JXRegistry list.
 java.util.Map regMap
          Map of registries by String name.
static java.lang.String SYNTH_PREFIX
          Prefix indicating that the class should be synthesized.
private  boolean synthEnabled
           
private  java.lang.String synthPrefix
           
 ClassTransformer xformer
          Responsible for instrumenting classes.
 
Fields inherited from class java.net.URLClassLoader
 
Fields inherited from class java.security.SecureClassLoader
 
Fields inherited from class java.lang.ClassLoader
 
Constructor Summary
JXClassLoader(java.net.URL[] cp, java.lang.ClassLoader parent, java.lang.String[] del, java.lang.String[] inc, java.lang.String[] exc)
          Constructor with full argument list.
JXClassLoader(java.net.URL[] cp, java.lang.String[] inc)
          Constructor with abbreviated argument list.
 
Method Summary
 void addClassXformer(ClassXformer xf)
          Add a class transformer.
 void addDelegated(java.lang.String prefix)
          Add a class name prefix to the list of those to be delegated to the parent.
 void addExcluded(java.lang.String prefix)
          Add a class name prefix to the list of those to be excluded from instrumentation.
 void addGraphXformer(GraphXformer xf)
          Add a graph transformer.
 void addIncluded(java.lang.String prefix)
          Add a class name prefix to the list of those to be instrumented.
 org.jxcl.reg.JXRegistry addJXRegistry(java.lang.String regName)
          Add a new JXRegistry to the list.
 void addMethodXformer(MethodXformer xf)
          Add a method transformer.
 void addPath(java.net.URL url)
          Add a path to the class loader's classpath.
static java.lang.String classFileName(java.lang.String className)
          Convert a class name into a file name by replacing dots with forward slashes and appending ".class".
private  boolean delegateTheClass(java.lang.String name)
          Do we delegate loading this to the parent?
protected  java.lang.Class findClass(java.lang.String name)
          Locate the class whose name is passed and define it.
protected  byte[] getClassData(java.lang.String className)
          Find a class along the class path and load it as a byte array.
 java.net.URL[] getClassPath()
           
 java.lang.String[] getDelegated()
           
 java.lang.String[] getExcluded()
           
 java.lang.String[] getIncluded()
           
 org.jxcl.reg.JXRegistry getRegistry(java.lang.String regName)
          Get a reference to a JXCL registry.
 java.lang.String getReport()
          Get reports from any or all registries.
 boolean getSynthEnabled()
          Get synthesizing-enabled flag.
 java.lang.String getSynthPrefix()
           
private  boolean instrumentTheClass(java.lang.String name)
          Should class be instrumented?
 java.lang.Class loadClass(java.lang.String name)
          Class loader.
 void setClassPath(java.lang.String cp)
          Convert classpath in normal form to URL[] and sets loader classpath to the corresponding value.
 void setExcluded(java.lang.String s)
          Sets the list of classes to be excluded from instrumentation.
 void setIncluded(java.lang.String s)
          Sets the list of classes to be instrumented.
 void setSynthEnabled(boolean b)
          Enable class synthesizing.
 java.lang.String urlsToString()
           
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findResource, findResources, getPermissions, getURLs, newInstance, newInstance, toString
 
Methods inherited from class java.security.SecureClassLoader
defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, 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, wait, wait, wait
 

Field Detail

FILE_PATH_DELIM_CHAR

public static final char FILE_PATH_DELIM_CHAR
Operating system specific


FILE_PATH_DELIM_STR

public static final java.lang.String FILE_PATH_DELIM_STR

CLASSPATH_DELIM_CHAR

public static final char CLASSPATH_DELIM_CHAR

CLASSPATH_DELIM_STR

public static final java.lang.String CLASSPATH_DELIM_STR

DELEGATED

public static final java.lang.String[] DELEGATED
Names of classes which must be loaded by the parent. There is one exception to this list: org.jxcl.JXIC, which is not delegated and not instrumented.


dels

private java.lang.String[] dels
XXX This is misleading! What's wanted is a copy.


delegated

private java.util.List delegated

excluded

private java.util.List excluded
Names of classes NOT to be instrumented. Names are matched as above. The excluded list is consulted first.


included

private java.util.List included
Names of classes to be instrumented. At this time no wildcards are permitted. Any class whose name begins with a string in the array will be instrumented, unless it is on the excluded list.


classPath

private java.util.List classPath
URLs in the order in which they are to be searched. Those ending in '/' are directories. Any others are jars.


parent

private java.lang.ClassLoader parent
Delegation class loader. Unless a class is to be instrumented (is on the inclusion list and not on the exclusion list), loading will be delegated to this class loader.


SYNTH_PREFIX

public static final java.lang.String SYNTH_PREFIX
Prefix indicating that the class should be synthesized.

See Also:
Constant Field Values

synthPrefix

private java.lang.String synthPrefix

synthEnabled

private boolean synthEnabled

xformer

public ClassTransformer xformer
Responsible for instrumenting classes.


cxf

java.util.List cxf
Configurable class transformers.


mxf

java.util.List mxf
Configurable method transformers.


gxf

java.util.List gxf
Configurable graph transformers.


regList

java.util.List regList
JXRegistry list.


regMap

public java.util.Map regMap
Map of registries by String name.

Constructor Detail

JXClassLoader

public JXClassLoader(java.net.URL[] cp,
                     java.lang.String[] inc)
Constructor with abbreviated argument list.


JXClassLoader

public JXClassLoader(java.net.URL[] cp,
                     java.lang.ClassLoader parent,
                     java.lang.String[] del,
                     java.lang.String[] inc,
                     java.lang.String[] exc)
Constructor with full argument list.

Method Detail

delegateTheClass

private boolean delegateTheClass(java.lang.String name)
Do we delegate loading this to the parent?


instrumentTheClass

private boolean instrumentTheClass(java.lang.String name)
Should class be instrumented?


classFileName

public static java.lang.String classFileName(java.lang.String className)
Convert a class name into a file name by replacing dots with forward slashes and appending ".class".


loadClass

public java.lang.Class loadClass(java.lang.String name)
                          throws java.lang.ClassNotFoundException
Class loader. Delegates the loading if specifically instructed to do so. Returns the class if it has already been loaded. Otherwise creates a class transformer if necessary and then passes the name to findClass.


findClass

protected java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Locate the class whose name is passed and define it. If the class name has the appropriate prefix and synthesizing it is enabled, it synthesizes it. Otherwise it searches for it along the class path. If indicated, it transforms (instruments) the class. Finally, it defines and returns the result.


urlsToString

public java.lang.String urlsToString()

getClassData

protected byte[] getClassData(java.lang.String className)
                       throws java.io.IOException
Find a class along the class path and load it as a byte array.


addPath

public void addPath(java.net.URL url)
Add a path to the class loader's classpath.


getClassPath

public java.net.URL[] getClassPath()

setClassPath

public void setClassPath(java.lang.String cp)
Convert classpath in normal form to URL[] and sets loader classpath to the corresponding value.


addDelegated

public void addDelegated(java.lang.String prefix)
Add a class name prefix to the list of those to be delegated to the parent.


getDelegated

public java.lang.String[] getDelegated()

addExcluded

public void addExcluded(java.lang.String prefix)
Add a class name prefix to the list of those to be excluded from instrumentation.


getExcluded

public java.lang.String[] getExcluded()

setExcluded

public void setExcluded(java.lang.String s)
Sets the list of classes to be excluded from instrumentation.


addIncluded

public void addIncluded(java.lang.String prefix)
Add a class name prefix to the list of those to be instrumented.


getIncluded

public java.lang.String[] getIncluded()

setIncluded

public void setIncluded(java.lang.String s)
Sets the list of classes to be instrumented.


getSynthEnabled

public boolean getSynthEnabled()
Get synthesizing-enabled flag.


setSynthEnabled

public void setSynthEnabled(boolean b)
Enable class synthesizing.


getSynthPrefix

public java.lang.String getSynthPrefix()

addClassXformer

public void addClassXformer(ClassXformer xf)
Add a class transformer.


addMethodXformer

public void addMethodXformer(MethodXformer xf)
Add a method transformer.


addGraphXformer

public void addGraphXformer(GraphXformer xf)
Add a graph transformer.


getRegistry

public org.jxcl.reg.JXRegistry getRegistry(java.lang.String regName)
Get a reference to a JXCL registry.


addJXRegistry

public org.jxcl.reg.JXRegistry addJXRegistry(java.lang.String regName)
Add a new JXRegistry to the list. An example of the argument is "org.jxcl.cover.stmt.StmtRegistry".


getReport

public java.lang.String getReport()
Get reports from any or all registries. XXX This should not be returning a String -- it might be huge.