Enum Hash Codes Are Non-Deterministic

2013-05-02 03:40UTC

An annoying discovery: Java Enum objects have non-deterministic hash codes. Specifically, a hash code is the Enum's identity (or memory address).

public final int hashCode()
{
    return super.hashCode();
}

So, should you ever make the same mistake as me, keying a HashMap with an Enum, strongly consider using EnumMap, instead.