Submitted On 16-JUN-2005
Bernhard.Mandl
The main problem with subclassing enums is that this would break the contract that you may compare enumerated values with
Submitted On 16-JUN-2005
Bernhard.Mandl
The main problem with subclassing enums is that this would break the contract that you may compare enumerated values by comparing for equal references. The number of values in the enumeration should also be constant and not extendable by subclassing.
These problems would NOT affect abstract enumerations becasue these contain only code to be inherited, but no enumerated values.
So why not keep the bug-id open as RFE? What's the problem?
Submitted On 26-MAY-2007
steevcoc
I see Bernhard.Mandl point above:
The subclass is limited to only one child level. There can be no grandchildren to conflict.
Submitted On 01-AUG-2007
I strongly support this RFE, I often have a need for this. It isn't a can of worms at all. Just let
abstract enum EnumA extends Enum { ... }
expand to a class
abstract class EnumA<E extends EnumA<E>> extends Enum<E> { ... }
and
abstract enum EnumB extends EnumA { ... }
to a class
abstract class EnumB<E extends EnumB<E>> extends EnumA<E> { ... }
and finally
enum EnumC extends EnumB { ... }
to a conrete enum class
class EnumC extends EnumB<EnumC> { ... }
and you're set. Of course Enum.valueOf() and Class.getEnumConstants() would only be applicable to concrete enum types.
Please reopen this RFE!
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|