Java · Hard · Pro
WeakHashMap and weak references — cache key eviction?
JavaCollectionsStaff
WeakHashMap
WeakHashMap holds keys via weak references—when the key object is only weakly reachable, GC can reclaim it and the entry disappears. Used for canonicalization caches tied to object lifetime (class loaders,…