private boolean isValidKey(Object key) {
if (key == null)
return false;
// Cheaper than instanceof Enum followed by getDeclaringClass
Class<?> keyClass = key.getClass();
return keyClass == keyType || keyClass.getSuperclass() == keyType;
}
As seen in the above method's last line, why does EnumMap implementation check for the key's superclass? If nothing can derive from an enum why is this check needed?