expungeStaleEntries in WeakHashMap

In WeakHashMap.expungeStaleEntries method of JDK 1.5, I see following code:

e = (Entry<K,V>) queue.poll()

But while creating Entry, only key is added to WeakReference:

Entry(K key, V value, ReferenceQueue<K> queue, int hash, Entry<K,V> next) {

super(key, queue);

this.value = value;

this.hash = hash;

this.next = next;

}

So my question is: The WeakReference has only key, so how come on polling queue an object of type Entry is retrieved?

[531 byte] By [nishantagrawala] at [2007-11-27 9:32:58]
# 1

I don't understand what it is that you don't understand. The entries in the queue are of type Entry<K,V>, so when you poll the queue that's what you get back.

private static class Entry<K,V> extends WeakReference<K> implements Map.Entry<K,V>

WeakReference having 'only key' doesn't have anything to do with it.

ejpa at 2007-7-12 22:52:48 > top of Java-index,Core,Core APIs...
# 2
Why are entries in Queue are of type Entry, when we are only passing Key to WeakReference constructor, as in following line :super(key, queue);
nishantagrawala at 2007-7-12 22:52:48 > top of Java-index,Core,Core APIs...
# 3
> Why are entries in Queue are of type Entry, when we are only passing Key to WeakReference constructorWhy would that be a reason why the queue entries shouldn't be of type Entry?
ejpa at 2007-7-12 22:52:48 > top of Java-index,Core,Core APIs...