if(concurrent) {
try {
atomicRemove.invoke(map, new Object[] { key, ref });
}
catch(IllegalAccessException e) {
throw new UndeclaredThrowableException(e);
}
catch(InvocationTargetException e) {
throw new UndeclaredThrowableException(e);
}
}
else if(map.get(key) == ref) {
map.remove(key);
}