This appears to be flawed. A WeakHashMap will delete elements when the key is no longer accessible. In this case the key is the WeakReference created in the `add()` method. This WeakReference object is immediately discarded, so the WeakHashMap will simply delete all the elements added to it.

If the key wasn't wrapped in a WeakReference, this might work, but personally I'd just leave this as it was since it won't leak memory (other than temporarily holding the WeakReference objects, which are tiny).