This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Unloading classes
- From: Jeff Sturm <jsturm at one-point dot com>
- To: Anthony Green <green at redhat dot com>
- Cc: java at gcc dot gnu dot org
- Date: Sun, 3 Nov 2002 21:05:04 -0500 (EST)
- Subject: Re: Unloading classes
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