System.identityHashCode is not guaranteed to be unique although in practise it almost always is.
I considered using
IdentityHashMap but I would have had to make it synchronised as I believe this code is potentially called from multiple threads and
Hashtable was synchronised too.
I don’t see how
OsgiServiceFactoryBean could ever lose reference to the bean so there should be no need to make the key a
WeakReference. I’m not opposed to doing that just in case if anyone thinks that would be better.
@Jonathan Doklovic It’s been 6 years since you committed this code so I understand if you don’t remember anything about it, but I mentioned you just in case you do.