net.janino
Class JavaSourceClassLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--net.janino.JavaSourceClassLoader

public final class JavaSourceClassLoader
extends java.lang.ClassLoader

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


Constructor Summary
JavaSourceClassLoader(java.lang.ClassLoader parentClassLoader, java.io.File[] optionalSourcePath, java.lang.String optionalCharacterEncoding, int 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.
 
Method Summary
protected  java.lang.Class findClass(java.lang.String name)
          Implementation of java.lang.ClassLoader.findClass(String).
static void main(java.lang.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.
 
Methods inherited from class java.lang.ClassLoader
defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaSourceClassLoader

public JavaSourceClassLoader(java.lang.ClassLoader parentClassLoader,
                             java.io.File[] optionalSourcePath,
                             java.lang.String optionalCharacterEncoding,
                             int 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:
parent -  
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)
Method Detail

main

public static void main(java.lang.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 ] net.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 java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Implementation of java.lang.ClassLoader.findClass(String).
Overrides:
findClass in class java.lang.ClassLoader
Throws:
java.lang.ClassNotFoundException -  
TunnelException - wraps a Scanner.ScanException
TunnelException - wraps a Parser.ParseException
TunnelException - wraps a IOException