[doc]Small modification on the WeakHashMap doc (original) (raw)
Charles Lee littlee at linux.vnet.ibm.com
Thu May 3 06:52:21 UTC 2012
- Previous message: hg: jdk8/tl/jdk: 7160714: Strange or obsolete @see tags in some exception java.util javadoc
- Next message: [doc]Small modification on the WeakHashMap doc
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi guys,
In the Implementation notes of WeakHashMap1, 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"./
<http://cr.openjdk.java.net/%7Elittlee/7166055/webrev.00/>
-- Yours Charles
- Previous message: hg: jdk8/tl/jdk: 7160714: Strange or obsolete @see tags in some exception java.util javadoc
- Next message: [doc]Small modification on the WeakHashMap doc
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]