"bstansberry(a)jboss.com" wrote : Oh, but my class above is intended to be passed
as a key to WeakHashMap. The ReferenceQueue polling will remove the only strong ref to
the Key, at which point the WeakHashMap will do its normal thing and make the Key/value
pair eligible for removal.
Hmmm ... trying to put your code into real life showed some issues.
The way you do your refQueue is wrong. :-)
And I don't see how you can do it right.
Since what you have to pass into WeakReference as Queue instance is the initial queue of
actual type of your WeakReference - the type that's gonna be GCed - in our case the
Class ref.
But in that case we cannot do this
| private void cleanKeyRefs()
| {
| Reference ref = null;
| while ((ref = refQueue.poll()) != null)
| {
| ((KeyRef) ref).key = null;
| }
| }
|
I'll try to do WeakCompositeKeyMap, doing something similar as what we do in
WeakValueHashMap.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4152343#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...