net.janino
Class ByteArrayClassLoader

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

public class ByteArrayClassLoader
extends java.lang.ClassLoader

This ClassLoader allows for the loading of JavaTM classes from a byte array, an java.io.InputStream or a java.io.File.


Constructor Summary
ByteArrayClassLoader()
           
ByteArrayClassLoader(java.lang.ClassLoader parent)
           
 
Method Summary
 void addClass(java.lang.String name, byte[] data)
          Adds a class that will be found by findClass(String).
 void addClass(java.lang.String name, java.io.File file)
          Adds a class that will be found by findClass(String).
 void addClass(java.lang.String name, java.io.InputStream inputStream)
          Adds a class that will be found by findClass(String).
protected  java.lang.Class findClass(java.lang.String name)
          Implements java.lang.ClassLoader.findClass(String).
 
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

ByteArrayClassLoader

public ByteArrayClassLoader()

ByteArrayClassLoader

public ByteArrayClassLoader(java.lang.ClassLoader parent)
Method Detail

addClass

public void addClass(java.lang.String name,
                     byte[] data)
Adds a class that will be found by findClass(String).
Parameters:
name - the name of the class
data - the data of the class in "class file format"

addClass

public void addClass(java.lang.String name,
                     java.io.InputStream inputStream)
              throws java.io.IOException
Adds a class that will be found by findClass(String).
Parameters:
name - the name of the class
inputStream - source of data of the class in "class file format"
Throws:
java.io.IOException - Problems reading from the inputStream

addClass

public void addClass(java.lang.String name,
                     java.io.File file)
              throws java.io.FileNotFoundException,
                     java.io.IOException
Adds a class that will be found by findClass(String).
Parameters:
name - the name of the class
file - the file that contains the data of the class in "class file format"
Throws:
java.io.FileNotFoundException - The file does not exist
java.io.IOException - Problems reading the class file

findClass

protected java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Implements java.lang.ClassLoader.findClass(String).
Overrides:
findClass in class java.lang.ClassLoader