PROPOSAL: abstract enums

Joseph D. Darcy Joe.Darcy at Sun.COM
Sun Mar 29 20:54:08 PDT 2009

Derek Foster wrote:
> AUTHOR: Derek Foster
> The Java Enumerated type feature is unlike similar features in any other language which preceded it. In prior languages, an enumerated type was simply a collection of integer constants. In contrast, Java's enumerated type is a rich datatype that has more in common with classes than it has with a simple constants. Enumerated types can contain complex data, as well as methods to operate on that data. Individual enumerators may be subclasses of the enumeration class that contains them, and may override methods to provide enumerator-specific behavior.


> Javadoc might possibly need to be updated to handle the possibility of an abstract enumerated type.

This proposal is incomplete.  There are many other possible impacts of 
this change, including serialization; see

    "So you want to change the Java Programming Language..."

for an account of all the aspects of the system adding regular enums 

Of the extensible and non-extensible version of enum pattern, the JSR 
201 expert group chose the non-extensible variant and many other 
decisions and details of the original enum design flow from that 
fundamental decision.  Revisiting that decision now is impractical.

Additionally, some of the advantages of extensible enums can be had by 
making different enum classes implement a common interface; for some 
discussion of that general pattern see

    "Mixing-in an Enum"

as well as an item in the 2nd edition of "Effective Java."


More information about the coin-dev mailing list