Possible Duplicate:
Why is softKeys() deprecated in Guava 10?
The reason why MapMaker.softKeys() is deprecated in JavaDoc:
Use softValues to create a memory-sensitive map, or weakKeys to create
a map that doesn’t hold strong references to the keys. This method is
scheduled for deletion in January 2013.This method is broken. Maps with soft keys offer no functional advantage over maps with weak keys, and they waste memory by keeping
unreachable elements in the map. If your goal is to create a
memory-sensitive map, then consider using soft values instead.Specifies that each key (not value) stored in the map should be
wrapped in a SoftReference (by default, strong references are used).
Softly-referenced objects will be garbage-collected in a globally
least-recently-used manner, in response to memory demand.
I don’t understand why soft value prefers over soft key? Any scenario? MapMaker.softValues() is still available. Thanks!
Maps with soft and weak items have two major use cases:
Caches. A map with soft values can act as a memory-sensitive cache. Due to semantics of soft reference entries of the cache are collected when free memory is needed.
Canonicalizing mappings. Sometimes you need to associate additional property (a value) with the existing object (a key). This association shouldn’t prevent the key from being collected, and it doesn’t make sense after key is collected. Such an association can be implemented as a map with weak keys.
Note that the use of soft keys instead of weak keys in the latter case doesn’t make any sense and causes unnecessary memory usage, so that soft keys have no practical use, that’s why they are deprecated.