Autoboxing is rather scary. While I fully understand the difference between ==
and .equals
I can\'t but help have the follow bug the hell out of m
A lot of people have problems with this issue, even people that write books about Java.
In Pro Java Programming, mere inches below were the author talks about issues with using auto-boxed Integers as a key in an IdentityHashMap, he uses auto-boxed Integer keys in a WeakHashMap. The example values he uses are greater than 128, so his garbage collection call succeeds. If someone were to use his example and use values smaller than 128 though, his example would fail (due to the key being perma-cached).