I\'ve been looking at the source code of the Enum class. It seems like a plain abstract class with a protected constructor to me. It\'s not final, it doesn\'t have any speci
It's only invalid to extend Enum
directly within the language. Any time you declare an enum
, that does create a subclass of Enum
.
The way the JLS prevents you from "manually" declaring a class which extends Enum
is simply to prohibit it explicitly. From JLS section 8.1.4:
It is a compile-time error if the ClassType names the class Enum or any invocation of it.
(Where ClassType
is the type you're extending.)
Without that rule, your code would have been perfectly valid.