ensure WeakHashMap.MyCell objects are registered with the ReferenceQueue

This commit is contained in:
Joel Dice 2009-09-01 17:22:31 -06:00
parent 49005f0746
commit 0a96f4c552

View File

@ -97,8 +97,10 @@ public class WeakHashMap<K, V> implements Map<K, V> {
public HashMap.Cell<K, V> next;
public int hashCode;
public MyCell(K key, V value, HashMap.Cell<K, V> next, int hashCode) {
super(key);
public MyCell(K key, ReferenceQueue queue, V value,
HashMap.Cell<K, V> next, int hashCode)
{
super(key, queue);
this.value = value;
this.next = next;
this.hashCode = hashCode;
@ -129,11 +131,11 @@ public class WeakHashMap<K, V> implements Map<K, V> {
}
}
private static class MyHelper<K, V>
private class MyHelper<K, V>
extends HashMap.MyHelper<K, V>
{
public HashMap.Cell<K, V> make(K key, V value, HashMap.Cell<K, V> next) {
return new MyCell(key, value, next, hash(key));
return new MyCell(key, queue, value, next, hash(key));
}
}
}