koala.dynamicjava.interpreter
Class TreeClassLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--koala.dynamicjava.interpreter.TreeClassLoader
All Implemented Interfaces:
ClassLoaderContainer

public class TreeClassLoader
extends java.lang.ClassLoader
implements ClassLoaderContainer

This class is responsible for loading bytecode classes


Field Summary
protected  java.util.Map classes
          The place where the interpreted classes are stored
protected  java.lang.ClassLoader classLoader
          The auxiliary class loader
protected  Interpreter interpreter
          The interpreter
protected  java.util.Map trees
          The syntax trees
 
Constructor Summary
TreeClassLoader(Interpreter i)
          Creates a new class loader
 
Method Summary
 void addTree(java.lang.String name, TypeDeclaration node)
          Adds a class syntax tree to the list of the loaded trees
 void addURL(java.net.URL url)
          Adds an URL in the class path
 java.lang.Class defineClass(java.lang.String name, byte[] code)
          Converts an array of bytes into an instance of class Class and links this class.
protected  java.lang.Class findClass(java.lang.String name)
          Finds the specified class.
 java.lang.ClassLoader getClassLoader()
          Returns the additional class loader that is used for loading classes from the net.
 java.util.Set getClassNames()
          Returns the names of the defined classes in a set
 TypeDeclaration getTree(java.lang.String name)
          Gets a tree
 boolean hasDefined(java.lang.String name)
          Whether a class was defined by this class loader
 
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
 

Field Detail

classes

protected java.util.Map classes
The place where the interpreted classes are stored

trees

protected java.util.Map trees
The syntax trees

interpreter

protected Interpreter interpreter
The interpreter

classLoader

protected java.lang.ClassLoader classLoader
The auxiliary class loader
Constructor Detail

TreeClassLoader

public TreeClassLoader(Interpreter i)
Creates a new class loader
Parameters:
i - the object used to interpret the classes
Method Detail

defineClass

public java.lang.Class defineClass(java.lang.String name,
                                   byte[] code)
Converts an array of bytes into an instance of class Class and links this class.
Throws:
java.lang.ClassFormatError - if the class could not be defined

getClassLoader

public java.lang.ClassLoader getClassLoader()
Returns the additional class loader that is used for loading classes from the net.
Specified by:
getClassLoader in interface ClassLoaderContainer
Returns:
null if there is no additional class loader

hasDefined

public boolean hasDefined(java.lang.String name)
Whether a class was defined by this class loader

getClassNames

public java.util.Set getClassNames()
Returns the names of the defined classes in a set

addTree

public void addTree(java.lang.String name,
                    TypeDeclaration node)
Adds a class syntax tree to the list of the loaded trees
Parameters:
name - the name of the type
node - the tree

getTree

public TypeDeclaration getTree(java.lang.String name)
Gets a tree

addURL

public void addURL(java.net.URL url)
Adds an URL in the class path

findClass

protected java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Finds the specified class.
Overrides:
findClass in class java.lang.ClassLoader
Parameters:
name - the name of the class
Returns:
the resulting Class object
Throws:
java.lang.ClassNotFoundException - if the class could not be find


Copyright ? 2001 Stephane Hillion. All Rights Reserved.