Re: class gc

Date view Thread view Subject view Author view

From: Godmar Back (gback@cs.utah.edu)
Date: Thu Dec 17 1998 - 16:17:57 EST


>
> > So it does keep them alive since the class entry pool is not walked.
>
> > Tell me why it should.
>
> For the same reason why classes loaded by the default class loader
> shouldn't be collected: people assume that static initializers will be
> run only once. Making a difference based on whether a class was
> loaded by the default class loader or another ClassLoader is not
> right, IMO.
>

Classes are kept alive by their objects, and loaders are kept alive by
the classes they defined.

In other words, a loader becomes unreachable iff all classes loaded by
it have become unreachable and there are no other references to that
loader.

Since we keep the entries in the class pool until the loader is finalized
(minus possible reattachment attacks, as we discuss in a separate thread
here), static initializer won't ever be run twice because the VM won't
ask the classloader to load/define a class. If the loader attempts it
itself, it will see duplicate definition cause the entry pool is consulted.

Does that make sense?

        - Godmar


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:57:20 EDT