At 02:20 PM 6/6/2003, email@example.com wrote:
> > Are you asking about section 12.7 in the JLS, or did you have something
> > else in mind?
> > I'm not aware of anything specific about class loader reachability.
>We have a vague recollection that there was a rule that:
>A) if an instance of a class is reachable, then the class loader is
>B) if the class loader is reachable, then any class object it loaded is
>reachable as well.
>However, I am pretty sure this rule doesn't make any sense. For example,
>if these were the only rules, then we could collect the class loader as
>soon as we load it, before it loads any classes.
>So I must be misremembering it. Does anyone have a clearer recollection
Originally there was a rule that said you could garbage collect a Class
object if there were no instances of that class object. That rule had
unfortunate consequences so that it was changed to you could garbage
collect a Class object if there were no instances of that Class and the
Class'es ClassLoader was unreachable (or already collected). What this
amounts to is that in determining reachability in addition to ordinary
references you need to count the implicit references given by (A) and (B).
You can certainly gc a ClassLoader before it loads any classes if there
aren't any other references to it.
>JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:46 EDT