JEP 301: Enhanced Enums

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Wed Dec 7 09:48:44 UTC 2016


Thanks for the feedback. I personally run into the lack of sharp typing  
several times and seen other people stumbling on it too.

Do you have some example in mind that will break - other than the ones 
listed in the JEP? In my mental model, the kind of surprises this 
introduces are very similar to anonymous inner class types - that is:

new Object() { void m() { } }.m();

this is legal code because the receiver expression doesn't have type 
Object - but has a sharper type (which can 'see' the additional member). 
This proposal is about doing the same with enums - which accidentally 
will sit well with adding generics (because in that case, the constants 
will have a richer generic type than their parent).

Maurizio


On 07/12/16 09:03, Remi Forax wrote:
> Now, If this proposal is accepted, at least, instead of changing the spec to introduce sharp types for all kind of enums, adding sharp type only for generics enums,
> it will break no code because generics enum currently do not compile.



More information about the platform-jep-discuss mailing list