org.codehaus.commons.compiler
Class AbstractJavaSourceClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by org.codehaus.commons.compiler.AbstractJavaSourceClassLoader
Direct Known Subclasses:
JavaSourceClassLoader, JavaSourceClassLoader

public abstract class AbstractJavaSourceClassLoader
extends java.lang.ClassLoader

A ClassLoader that, unlike usual ClassLoaders, does not load byte code, but reads Java™ source code and then scans, parses, compiles and loads it into the virtual machine.

As with any ClassLoader, it is not possible to "update" classes after they've been loaded. The way to achieve this is to give up on the AbstractJavaSourceClassLoader and create a new one.


Nested Class Summary
static interface AbstractJavaSourceClassLoader.ProtectionDomainFactory
           
 
Field Summary
protected  AbstractJavaSourceClassLoader.ProtectionDomainFactory optionalProtectionDomainFactory
           
 
Constructor Summary
AbstractJavaSourceClassLoader()
           
AbstractJavaSourceClassLoader(java.lang.ClassLoader parentClassLoader)
           
 
Method Summary
static void main(java.lang.String[] args)
          Read Java™ source code for a given class name, scan, parse, compile and load it into the virtual machine, and invoke its "main()" method with the given arguments.
abstract  void setDebuggingInfo(boolean lines, boolean vars, boolean source)
           
 void setProtectionDomainFactory(AbstractJavaSourceClassLoader.ProtectionDomainFactory optionalProtectionDomainFactory)
           
abstract  void setSourceFileCharacterEncoding(java.lang.String optionalCharacterEncoding)
           
abstract  void setSourcePath(java.io.File[] sourcePath)
           
 
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, 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

optionalProtectionDomainFactory

protected AbstractJavaSourceClassLoader.ProtectionDomainFactory optionalProtectionDomainFactory
Constructor Detail

AbstractJavaSourceClassLoader

public AbstractJavaSourceClassLoader()

AbstractJavaSourceClassLoader

public AbstractJavaSourceClassLoader(java.lang.ClassLoader parentClassLoader)
Method Detail

setSourcePath

public abstract void setSourcePath(java.io.File[] sourcePath)
Parameters:
sourcePath - The sequence of directories to search for Java™ source files

setSourceFileCharacterEncoding

public abstract void setSourceFileCharacterEncoding(java.lang.String optionalCharacterEncoding)
Parameters:
optionalCharacterEncoding - if null, use platform default encoding

setDebuggingInfo

public abstract void setDebuggingInfo(boolean lines,
                                      boolean vars,
                                      boolean source)
Parameters:
lines - Whether line number debugging information should be generated
vars - Whether variables debugging information should be generated
source - Whether source file debugging information should be generated

setProtectionDomainFactory

public final void setProtectionDomainFactory(AbstractJavaSourceClassLoader.ProtectionDomainFactory optionalProtectionDomainFactory)
See Also:
ClassLoader.defineClass(String, byte[], int, int, ProtectionDomain)

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Read Java™ source code for a given class name, scan, parse, compile and load it into the virtual machine, and invoke its "main()" method with the given arguments.

Usage is as follows:

   java org.codehaus.commons.compiler.AbstractJavaSourceClassLoader [ option ] ... class-name [ argument ] ...

   option:
     -sourcepath colon-separated-list-of-source-directories
     -encoding character-encoding
     -g                           Generate all debugging info
     -g:none                      Generate no debugging info
     -g:{source,lines,vars}       Generate only some debugging info
 

Throws:
java.lang.Exception


Copyright © 2001-2011. All Rights Reserved.