On 3 November 2013 22:07, Niko Matsakis <n...@alum.mit.edu> wrote: > - Aren't we talking about weak refs? I thought a weakmap in JS was a > done deal? I believe Java's weak refs, and in particular weak > references when combined with [reference queues][1], are pretty > similar to what the strawman proposed. > > - Why do you say Java doesn't have a weakmap? What is the > [WeakHashMap][2] class if not a WeakMap? Presumably we are using the > term differently? (I imagine there are many variations of weakmaps > which vary in subtle but significant ways)
In Java's WeakHashMap holds a strong reference to the value. As such a cycle from the value to the key is not collectable. One can mitigate that via storing a weak reference to the value, but then the GC can collect the value and it is observable. Similarly reference queues do not cover the functionality provided by the WeakMap when both the map and the key must be reachable for the value to stay alive. _______________________________________________ dev-tech-js-engine-internals mailing list dev-tech-js-engine-internals@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals