|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.lang.ClassLoader
|
+--com.svincent.smalljava.SmallClassLoader
Allows dynamic loading and execution of Smalljava code.
Beware. JDK 1.2 added new rules regarding the garbage collection of classes. In particular,
"A class or interface may be unloaded if and only if its class loader is unreachable (the definition of unreachable is given in JLS 12.6.1). Classes loaded by the bootstrap loader may not be unloaded."
Here is Sun's technical rationale for this decision
This means that you must be careful about how you use dynamically generated classes. One model that is guaranteed to work is to create a ClassLoader, define and execute a class using it, and then drop the ClassLoader on the floor. This works for some applications, but not all.
Fancier schemes are possible, and may be documented here later. It is possible that a fancy scheme using weak references and many ClassLoaders may be implemented in Smalljava. If that happens, these facilities will be made available as part of the Smalljava API.
There may be issues with this ClassLoader, particularly with respect to redefining classes again and again. This has not been thoroughly tested.
| Constructor Summary | |
SmallClassLoader()
|
|
| Method Summary | |
java.lang.Class |
findClass(java.lang.String name)
Finds a class, trying the current installed classes first, and then the system classloader, if all else fails. |
void |
installClass(SmallClass smallClass)
Install the given SmallClass into this ClassLoader. |
java.lang.Class |
loadClass(SmallClass smallClass)
Requests the immediate loading of the given SmallClass object. |
| 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 |
public SmallClassLoader()
| Method Detail |
public java.lang.Class loadClass(SmallClass smallClass)
public void installClass(SmallClass smallClass)
public java.lang.Class findClass(java.lang.String name)
throws java.lang.ClassNotFoundException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
This is documentation for Moksa Prolog, which can be found at http://www.svincent.com/moksa/
Copyright © 1999 Shawn P. Vincent.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.