src/share/classes/java/util/WeakHashMap.java

Print this page

        

@@ -92,11 +92,14 @@
  * strongly refer to some other key object whose associated value object, in
  * turn, strongly refers to the key of the first value object.  One way
  * to deal with this is to wrap values themselves within
  * <tt>WeakReferences</tt> before
  * inserting, as in: <tt>m.put(key, new WeakReference(value))</tt>,
- * and then unwrapping upon each <tt>get</tt>.
+ * and then unwrapping upon each <tt>get</tt>. However, as the use of
+ * <tt>WeakReference</tt> 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".
  *
  * <p>The iterators returned by the <tt>iterator</tt> method of the collections
  * returned by all of this class's "collection view methods" are
  * <i>fail-fast</i>: if the map is structurally modified at any time after the
  * iterator is created, in any way except through the iterator's own