I am trying to construct a dictionary cache which contains the weakreference of the passed-in key as the index,instead of the original key.
The source is below - and the line where it fails compilations is indicated.
I need help on the proper way to resolve this error.
public class ProxyWeakReference extends WeakReference{
public ProxyWeakReference(Object o, ReferenceQueue q)
{
super(o,q);
........
}
}
public class SafeQueueMap<K,V>{
ConcurrentMap<WeakReference<K>,V> d=new ConcurrentHashMap<ProxyWeakReference<K>,V>();
ReferenceQueue refQueue=new ReferenceQueue();
public void put(K k ,V v){
WeakReference<K> r=new ProxyWeakReference(k,refQueue);<==FAILS ON GENERIC PARAMETER
d.put(r,v);
}
......
......
}