Web Site

org.codehaus.janino
Class JavaSourceClassLoader

java.lang.Object
  extended byjava.lang.ClassLoader
      extended byorg.codehaus.janino.JavaSourceClassLoader

public class JavaSourceClassLoader
extends ClassLoader

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


Nested Class Summary
static interface JavaSourceClassLoader.ProtectionDomainFactory
           
 
Constructor Summary
JavaSourceClassLoader(ClassLoader parentClassLoader, File[] optionalSourcePath, String optionalCharacterEncoding, DebuggingInformation debuggingInformation)
          Set up a JavaSourceClassLoader that finds JavaTM source code in a file that resides in either of the directories specified by the given source path.
JavaSourceClassLoader(ClassLoader parentClassLoader, ResourceFinder sourceFinder, String optionalCharacterEncoding, DebuggingInformation debuggingInformation)
          Set up a JavaSourceClassLoader that finds JavaTM source code through a given ResourceFinder.
 
Method Summary
protected  Class findClass(String name)
          Implementation of ClassLoader.findClass(String).
static void main(String[] args)
          Read JavaTM source code for a given class name, scan, parse, compile and load it into the virtual machine, and invoke its "main()" method.
 void setProtectionDomainFactory(JavaSourceClassLoader.ProtectionDomainFactory protectionDomainFactory)
           
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, 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
 

Constructor Detail

JavaSourceClassLoader

public JavaSourceClassLoader(ClassLoader parentClassLoader,
                             File[] optionalSourcePath,
                             String optionalCharacterEncoding,
                             DebuggingInformation debuggingInformation)
Set up a JavaSourceClassLoader that finds JavaTM source code in a file that resides in either of the directories specified by the given source path.

Parameters:
parentClassLoader - See ClassLoader
optionalSourcePath - A collection of directories that are searched for JavaTM source files in the given order
optionalCharacterEncoding - The encoding of the JavaTM source files (null for platform default encoding)
debuggingInformation - What kind of debugging information to generate

JavaSourceClassLoader

public JavaSourceClassLoader(ClassLoader parentClassLoader,
                             ResourceFinder sourceFinder,
                             String optionalCharacterEncoding,
                             DebuggingInformation debuggingInformation)
Set up a JavaSourceClassLoader that finds JavaTM source code through a given ResourceFinder.

Parameters:
parentClassLoader - See ClassLoader
sourceFinder - Used to locate additional source files
optionalCharacterEncoding - The encoding of the JavaTM source files (null for platform default encoding)
debuggingInformation - What kind of debugging information to generate
Method Detail

main

public static void main(String[] args)
Read JavaTM source code for a given class name, scan, parse, compile and load it into the virtual machine, and invoke its "main()" method.

Usage is as follows:

   java [ java-option ] org.codehaus.janino.JavaSourceClassLoader [ option ] ... class-name [ arg ] ... 
     java-option Any valid option for the Java Virtual Machine (e.g. "-classpath colon-separated-list-of-class-directories") 
     option:
       -sourcepath colon-separated-list-of-source-directories 
       -encoding character-encoding
 


findClass

protected Class findClass(String name)
                   throws ClassNotFoundException
Implementation of ClassLoader.findClass(String).

Throws:
ClassNotFoundException
TunnelException - wraps a Scanner.ScanException
TunnelException - wraps a Parser.ParseException
TunnelException - wraps a CompileException
TunnelException - wraps a IOException

setProtectionDomainFactory

public void setProtectionDomainFactory(JavaSourceClassLoader.ProtectionDomainFactory protectionDomainFactory)

Web Site