Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6423502
Votes 0
Synopsis (coll) Add value-weak version of WeakHashMap
Category java:classes_util
Reported Against
Release Fixed
State 5-Cause Known, request for enhancement
Priority: 5-Very Low
Related Bugs 4429536 , 4175502
Submit Date 09-MAY-2006
Description
A DESCRIPTION OF THE REQUEST :
In order to model a cache, it is quite useful to have a class similar to WeakHashMap. But, in my opinion, this class is designed wrong. It should not reference the keys by WeakReferences, but the values.

An example:

Imagine a cache for images. A quite useful model would be a map, where you put image values with key-reference by their pathname (HashMap<String, Image>)
So, if an image is not references anywhere, it could be deleted (and garbage collected) from the cache and reloaded if needed again afterwards.

The class WeakHashMap is NOT useful for this kind of behaviour, since it weakly references the keys, which would be the pathname in this example. But the keys in any cachmodel are always known and present; its the values you want to cache (and maybe remove if not used).

JUSTIFICATION :
Caching is very important and widely used in many programs.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
maybe a whole cache package would be nice with different kind of caches, not only a memory-based one
ACTUAL -
see description

CUSTOMER SUBMITTED WORKAROUND :
write your own cache
Posted Date : 2006-05-09 19:13:36.0
Work Around
N/A
Evaluation
Looks like a dup of the ancient

4175502: (coll) java.util: Add WeakValueHashMap class
Posted Date : 2006-05-09 19:13:36.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang