enhanced enums - back from the dead?

Brian Goetz brian.goetz at oracle.com
Tue Dec 11 20:15:22 UTC 2018


This uber-conservative approach seems a pretty reasonable approach to 
me; after all, enums are a language feature, and Enum<T> is a 
constrained class (can't implement it directly), so it is not 
unreasonable to define its typing wrt its supertypes specially.

So, let's get back to Maurizio's original question, which is: At one 
point, we thought this feature was pretty cool, and invested some work 
in it.  Then we ran into a roadblock, and wrote it off.  Now, we've got 
a reasonable way to clear the roadblock. Which brings us back to:

  - Do we still like the features described in JEP 301?

And, if we're not sure about that, what can we do to get more sure?


>> There’s an even more conservative option: restrict this only to the 
>> type variable of Enum<T extends Enum<T>>, not just to the type 
>> variables of all supertypes of an enum.  Then, the asymmetry is 
>> undetectable, in that it is illegal for a non-enum class to extend 
>> Enum, right?
>>
> Yes, that would be the most conservative. If we took that path, I 
> think a more direct way to describe/specify it, is to say that a raw 
> enum reference (e.g. Foo) has a special direct supertype Enum<Foo> and 
> leave all other rules untouched.
>
> Maurizio
>



More information about the amber-spec-experts mailing list