If you compile an enum like
enum Suit {SPADES, HEARTS, CLUBS, DIAMONDS}
You will see that the generated bytcodes (i.e. javap -p Suit
) correspond to a synthetic class:
final class Suit extends java.lang.Enum<Suit> {
public static final Suit SPADES;
public static final Suit HEARTS;
public static final Suit CLUBS;
public static final Suit DIAMONDS;
private static final Suit[] $VALUES;
public static Suit[] values();
public static Suit valueOf(java.lang.String);
private Suit();
}
So, instances of the enum are static members of the class itself. Then I think the only way in which this could be garbage collected would be if the class itself is garbage collected, which is very unlikely to happen if it was loaded by the system class loader.