Re: JavaMemoryModel: When can a classloader be unloaded

From: Thomas Hawtin (
Date: Wed May 19 2004 - 22:42:13 EDT

Bill Pugh wrote:
> But we couldn't absolutely convince ourselves that running a static method
> of a class ensures the class is reachable.
> (By the way, section 12.7 of the JLS (2nd edition) says "A class or
> interface may
> be unloaded if and only if its defining class loader may be reclaimed
> by the
> garbage collector as discussed in 12.6." But it isn't discussed there.

I assume that comment refers to the reclamation of objects in general,
not just class loaders. In particular (start of 12.6.1) "A reachable
object is any object that can be accessed in any potential continuing
computation from any live thread."

In the case quoted if both the class of class loader can't be reached
(through class constants, the Method, security managers, exceptions, the
thread, etc), as there's no finalizers, the objects are reclaimable. It
would be a bit freaky though.

Tom Hawtin

JavaMemoryModel mailing list -

This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:01:07 EDT