Unloading classes

Jeff Sturm jsturm@one-point.com
Sun Nov 3 18:05:00 GMT 2002


On 3 Nov 2002, Anthony Green wrote:
> On Sun, 2002年11月03日 at 17:16, Jeff Sturm wrote:
> > Also, a classloader must keep strong references to its loaded classes.
>> Why is that?

It's the simplest way to satisfy the condition that a class cannot be
unloaded while its classloader is reachable, as described in JLS 12.7:
"Since we can never guarantee that unloading a class or interface whose
loader is potentially reachable will not cause reloading, and reloading is
never transparent, but unloading must be transparent, it follows that one
must not unload a class or interface while its loader is potentially
reachable. A similar line of reasoning can be used to deduce that classes
and interfaces loaded by the bootstrap loader can never be unloaded."
> Another interesting question is how to handle System.loadLibrary(). Can
> we dlclose() them when the class calling System.loadLibrary is
> finalized?

I think you need to guarantee no static method of the class is executing
when you dlclose(). This is hard with the current GC.
Jeff


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /