DynamicJava Javadoc: Class TreeClassLoader

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## koala.dynamicjava.interpreter
Class TreeClassLoader

    java.lang.Object
      |
      +--java.lang.ClassLoader
            |
            +--java.security.SecureClassLoader
                  |
                  +--koala.dynamicjava.interpreter.TreeClassLoader

All Implemented Interfaces:
  ClassLoaderContainer

public class TreeClassLoader
extends java.security.SecureClassLoader
implements ClassLoaderContainer

This class is responsible for loading bytecode classes

All classes created by `TreeClassLoader`s have an identical `CodeSource`. This code source has no certificates but may have a location. The latter is set to the value of the system property with the value of `CODE_SOURCE_URL_PROPERTY` as key, if it is a valid URL. If the property is defined but its value is not a valid URL, the location of the code source is set to `null`. If the property is not defined, the value of `DEFAULT_CODE_SOURCE_URL` is used as location.

Field Summary
`protected java.util.Map` | `classes` The place where the interpreted classes are stored
`protected java.lang.ClassLoader` | `classLoader` The auxiliary class loader
`static java.lang.String` | `CODE_SOURCE_URL_PROPERTY` Name of the system property to define the value for the URL of the `CodeSource` assigned to classes created by this classloader.
`protected static java.security.CodeSource` | `codeSource` The code source for classes defined by instances of `TreeClassLoader`.
`static java.lang.String` | `DEFAULT_CODE_SOURCE_URL` The default value for the `CodeSource` URL.
`protected Interpreter` | `interpreter` The interpreter
`protected java.util.Map` | `trees` The syntax trees

Constructor Summary
`TreeClassLoader(Interpreter i)` Creates a new class loader
`TreeClassLoader(Interpreter i, java.lang.ClassLoader cl)` 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.security.SecureClassLoader
`defineClass, getPermissions`

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

### DEFAULT_CODE_SOURCE_URL

    public static java.lang.String DEFAULT_CODE_SOURCE_URL

  The default value for the `CodeSource` URL. May be overriden by setting the system property with name given by the value of `CODE_SOURCE_URL_PROPERTY`.

### CODE_SOURCE_URL_PROPERTY

    public static java.lang.String CODE_SOURCE_URL_PROPERTY

  Name of the system property to define the value for the URL of the `CodeSource` assigned to classes created by this classloader. The default value is the value of `DEFAULT_CODE_SOURCE_URL`.

  If the property value is not a wellformed URL, the URL is set to `null`.

### codeSource

    protected static java.security.CodeSource codeSource

  The code source for classes defined by instances of `TreeClassLoader`. Initializes when `TreeClassLoader` is loaded the first time.
  See Also:
    `DEFAULT_CODE_SOURCE_URL`, `CODE_SOURCE_URL_PROPERTY`

### 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

### TreeClassLoader

    public TreeClassLoader(Interpreter i,
                           java.lang.ClassLoader cl)

  Creates a new class loader
  Parameters:
    `i` - the object used to interpret the classes
    `cl` - the auxiliary class loader used to load external 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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001 Stephane Hillion. All Rights Reserved.