[kaffe] Kaffe CVS: kaffe hkraemer
Dalibor Topic
robilad@yahoo.com
Tue May 20 06:07:02 2003
Hallo Helmer,
--- Helmer Krämer <hkraemer@freenet.de> wrote:
> On Mon, 19 May 2003 14:20:51 -0700 (PDT)
> Dalibor Topic <robilad@yahoo.com> wrote:
> > I believe that's a problem built for WeakHashMaps ;) So I'll try to create
> a
> > patch that stores ClassLoaders separately in a WeakHashMap and see if that
> > helps.
>
> Wasn't there some problem with gc'ing classes and the
> singleton design pattern? That is if you have something
> like this:
thanks for the tip, I've found this article on JavaWorld that explains the
problem in some detail:
http://www.javaworld.com/javaworld/javatips/jw-javatip52.html
> Strongly referencing a class from the classloader that loaded it
> solves this problem, since a class can then only be gc'ed if its
> defining classloader can be gc'ed, which means that nobody is able
> to access the singleton anyway. This in turn would mean that the
> test in its current form is wrong, the failure is a correct result
> and we should fix the test case and should better leave the rest
> of the vm untouched...
I gave it a shot using a static WeakHashMap to store a map of (classloader ->
map of(name -> class)), removing the direct reference to the loadedClasses
hashmap. Didn't work as expected, i.e. ClassGC still failed. Then I tried to
also keep class loaders away from the (name -> class) map, but that wasn't
helpful either. Ugh.
What puzzles me is that the ClassGC test works with Sun's Java 1.4. It unloads
the classes all right, and loads them back again. I guess we should go through
the diffs and see where a new reference to the class loader has been added.
cheers,
dalibor topic
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com