com.dalsemi.system.classloader
Class TINIClassLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--com.dalsemi.system.classloader.TINIClassLoader

public final class TINIClassLoader
extends java.lang.ClassLoader

A simple ClassLoader implementation that can be used by applications to load classes stored in files in the classpath. This class also provides some utility class loading methods, such as class unloading and returning the class path.


Constructor Summary
TINIClassLoader()
          Creates a new TINIClassLoader that can be used to load class files from the file system.
 
Method Summary
static void addDynamicClass(byte[] code, int cnum)
          Adds bytes representing a TINI Class File as a dynamically loaded class.
static void addTrashHeap(byte[] heap, int cnum, java.lang.ClassLoader cl)
          Adds bytes representing a TINI Class File's reflection information, referred to as the Trash Heap.
static java.util.StringTokenizer getClasspath()
          Returns the classpath pre-pended by the 'boot' classpath.
 java.lang.Class loadClass(java.lang.String classname, boolean resolve_it)
          Definition of the loadClass method to override the abstract declaration in java.lang.ClassLoader.
static void unloadClasses(java.lang.ClassLoader cl)
          Provides a mechanism for applications to remove the memory associated with classes loaded by a certain java.lang.ClassLoader object.
 
Methods inherited from class java.lang.ClassLoader
defineClass, defineClass, findLoadedClass, findSystemClass, getResource, getResourceAsStream, getSystemResource, getSystemResourceAsStream, loadClass, resolveClass, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TINIClassLoader

public TINIClassLoader()
Creates a new TINIClassLoader that can be used to load class files from the file system.
Method Detail

loadClass

public java.lang.Class loadClass(java.lang.String classname,
                                 boolean resolve_it)
                          throws java.lang.ClassNotFoundException
Definition of the loadClass method to override the abstract declaration in java.lang.ClassLoader. Note that the resolve_it argument is always ignored. The class is always resolved.
Overrides:
loadClass in class java.lang.ClassLoader
Parameters:
classname - class name to resolve to a java.lang.Class file
resolve_it - ignored, the class is always resolved
Throws:
java.lang.ClassNotFoundException - if a definition for the class could not be found

getClasspath

public static java.util.StringTokenizer getClasspath()
Returns the classpath pre-pended by the 'boot' classpath. Applications that need to search the classpath for a resource should use code similar to the following:
       StringTokenizer st = getClasspath();
       while (st.hasMoreElements())
       {
           String path = st.nextToken();
           file = new File(path, classname+".class");
           if (file.exists())
           {
               break;
           }
           file = null;
       }
 
Currently the 'boot' classpath is /tiniext, and is similar to [JDK]/jre/lib/ext on PC implementations of the Java Virtual Machine.
Returns:
An enumeration of classpath Strings.

addDynamicClass

public static void addDynamicClass(byte[] code,
                                   int cnum)
Adds bytes representing a TINI Class File as a dynamically loaded class. Applications should not use this method with the exception of the Client-Server pre-convertor, which pre-converts dynamically loaded classes on the Server and then transfers the bytes to TINI. Please see documentation on the host-side application TINIClassServer for more information. Note that once a byte array has been passed to this method, it should no longer be used from Java. It is marked and read by the native virtual machine. Any alterations of the bytes will cause unpredictable behavior.
Parameters:
code - buffer containing the converted class file
cnum - class number for this new class

addTrashHeap

public static void addTrashHeap(byte[] heap,
                                int cnum,
                                java.lang.ClassLoader cl)
Adds bytes representing a TINI Class File's reflection information, referred to as the Trash Heap. Applications should not use this method with the exception of the Client-Server pre-convertor, which pre-convertes dynamically loaded classes on the Server and then transfers the bytes to TINI. Please see documentation on the host-side application TINIClassServer for more information. Note that once a byte array has been passed to this method, it should no longer be used from Java. It is marked and read by the native virtual machine. Any alterations of the bytes will cause unpredictable behavior.
Parameters:
code - buffer containing the converted reflection information
cnum - class number taht this reflection information belongs to
cl - java.lang.ClassLoader object used to load this class

unloadClasses

public static void unloadClasses(java.lang.ClassLoader cl)

Provides a mechanism for applications to remove the memory associated with classes loaded by a certain java.lang.ClassLoader object. Since finalizers do not work on TINI, this method is exposed to try to reclaim space consumed by the code and reflection information of a set of classes.

NOTE: This function does expose some possible dangerous behavior. Once the ClassLoader has been unloaded, the application will become unstable if it tries to use:

  • an instance of an Object whose class was loaded by the java.lang.ClassLoader
  • a java.lang.Class object that was loaded by java.lang.ClassLoader
  • the java.lang.ClassLoader that was unloaded
Parameters:
cl - all classes loaded by this java.lang.ClassLoader object will be unloaded, any memory associated with these classes will be released, even if instances of this Object or its java.lang.Class Object still exist


Also see:
o TINI 1.16 API, Optional Modules
o TINI Home Page
o 1-Wire API

o JDK 1.1

Last update Wed Jun 8 17:19:36 CDT 2005