commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andy Malakov" <>
Subject [collections] new feature request: (WeakIdentityHashMap)
Date Wed, 28 Jan 2004 19:14:46 GMT
Hello All,

I would like to ask your opinion on providing WeakIdentityHashMap features to ReferenceMap.

Object cache is often implemented using ReferenceMap (WeakHashMap). This class delegates decision
on when to de-cache an objects on
Java GC.

In many systems Java objects that represent database instances use database identity: methods
Object.equals(Object) and
Object.hashCode() are redefined to use database identity (identity defined in terms of object
table + object primary keys).

When traditional java.util.Map is used to implement database caches different instances of
the same database objects present a
problem: instances override each other. Class  java.util.IdentityHashMap (Apache Collections
3.0: IdentityMap) can be used to solve
this problem - this approach uses System.identityHashCode() to obtain reference hashCode and
Java comparison operator to compare
keys (and values).

What I need is functionality of IdentityMap combined with WeakReference-based keys.

Is it possible to extend ReferenceMap with an ability to use reference identity instead of
object identity? I can send you my
prototype if you are interested (it adds about ten lines of code to ReferenceMap).

Here are some links to Sun's bug parade pages that describe similar feature request for Java's

P.S. There is a need for this feature in Apache DB-OJB project.

All the Best,

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message