> [ Diversion:- Incidentally this shows that a class in the JVM
> is not the same thing as a java type. Im working on this
> because I think it means I can load a new class def into a
> still running jvm without removing the old.
>
Each class loaded by the JVM has one class loader associated with it.
You can not remove an already loaded class from a class loader since the
ClassLoader class keeps a private reference (I think it uese a
HashTable, but I might be wrong) to each loaded class. Prior to
searching through the class path, the class loader checks if the class
has been already loaded and if so it returns a handle to the already
loaded class object. Unfortunately (or fortunately, since if you think
about what could happen if you were allowed to mess around with the
ClassLoaders private references, you might end up with several versions
of one class which you would have no way of distinguishing between) you
can not modify these references. But you can have multiple class
loaders, and that is what for instance a JVM in a browser have. The nice
partt of this is that the same class loaded by two different class
loaders are considered to be *different* by the JVM. They don't even
share static data with each other.
Thus the only way to load a new class definition into a JVM is to use a
new class loader.
There are some other problems with class loaders which I think is a
buggy implementation, but I don't know if SUN agrees with me. When using
JNI and native libraries, you can *not* load the same native library
with two different class loaders if they use exactly the same path to
the native library. If they use different paths it works as it should.
/John
--
John Olsson mailto:[EMAIL PROTECTED]
Ericsson Radio AB, Box 1248, S-581 12 Linkoping
-------------------------------------------------------------
Phone: +46 13 321070 ECN: 868 1070 Fax: +46 13 287370
-------------------------------------------------------------
I was doing object-oriented assembly when I was 1 year old...
For some reason my mom insists on calling it "Playing with blocks"