From J. Bloch
A ... source of memory leaks is listeners ... The best way to ensure that callbacks are garbage collected promptly is to store o
While you can indeed use Collections.newSetFromMap() to get a WeakSet, it's use cases are actually quite limited.
If you want to implement something like String.intern() you might want to have a look at Guava's Interners.newWeakInterner() functionality instead.
String.intern()