javadoc on java.util.WeakHashMap
I thought it might be wise to have a wider consensus here before formally reporting it via JDK Bug Parade.
The description of WeakHashMap contains the following:
... In particular, even if you synchronize on a WeakHashMap instance and invoke none of its mutator methods, it is possible for ...
(Editted in terms of points for ease of view ;) )
1) the size method to return smaller values over time
2) the isEmpty method to return false and then true
3) the containsKey method to return true and later false for a given key
4) the get method to return a value for a given key but later return null
5) the put method to return null and the remove method to return false for a key that previously appeared to be in the map
6) successive examinations of the key set, the value collection, and the entry set to yield successively smaller numbers of elements.
The problem is on points (3) and (4) - if I'm holding a reference to the very key that I'm testing against the Map, how is it possible for the relevant Entry to be discarded between 2 retrieval calls if no mutator methods are called in between?