[doc]Small modification on the WeakHashMap doc
Charles Lee
littlee at linux.vnet.ibm.com
Mon May 28 07:36:09 UTC 2012
Hi devs,
I'd like to propose a new minor change for the WeakHashMap doc, which I
got it from David :-)
Would anyone got some time to take a look this fix[1]?
1. http://cr.openjdk.java.net/~littlee/7166055/webrev.01/
<http://cr.openjdk.java.net/%7Elittlee/7166055/webrev.01/>
On 05/07/2012 11:45 AM, David Holmes wrote:
> Hi Charles,
>
> On 7/05/2012 1:05 PM, Charles Lee wrote:
>> Does anyone interested in this issue?
>
> Interest and time are two different things :)
>
> A shorter form would be:
>
> "If the values in the map do not rely on the map holding strong
> references to them, then one way to deal with this is ...
>
> David
>
>> On 05/03/2012 02:52 PM, Charles Lee wrote:
>>> Hi guys,
>>>
>>> In the Implementation notes of WeakHashMap[1], says:
>>>
>>> /One way to deal with this is to wrap values themselves within
>>> WeakReferences before inserting, as in: m.put(key, new
>>> WeakReference(value)), and then unwrapping upon each get./
>>>
>>> However, it is not concise and a little misleading. Because the value
>>> in the WeakReference can be GC'd if there are no strong reference to
>>> it. This behaviour surprises some customers.
>>> How about add a statement like [2]:
>>>
>>> /However, as the use of WeakReference in this manner will not prevent
>>> value objects from being GC'd, this approach is only useful when
>>> entries in the map are not relied upon for keeping the underlying
>>> value objects "live"./
>>>
>>>
>>>
>>>
>>> [1]:
>>> http://docs.oracle.com/javase/7/docs/api/java/util/WeakHashMap.html
>>> [2]: http://cr.openjdk.java.net/~littlee/7166055/webrev.00/
>>> <http://cr.openjdk.java.net/%7Elittlee/7166055/webrev.00/>
>>>
>>
>>
>
--
Yours Charles
More information about the core-libs-dev
mailing list