enhanced enums - back from the dead?

Brian Goetz brian.goetz at oracle.com
Wed Dec 12 17:58:53 UTC 2018

> Secondly, it's hard to imagine there being any unforeseen consequences of switching on a long. Here, I don't really know how to think it through yet. I would appreciate any "here's how we know that the changes we need to support this will have no user-visible consequences at all except for X, Y, and Z" type of explanation we have (apologies if I missed it).

Since you’re always on the lookout for “how can we use the Google codebase to answer questions about this”, here’s one: look for classes that implement the “type safe enum pattern” — ones with an inaccessible constructor, and a pile of pre-baked instances stuffed in static fields.  Then ask yourself, why wasn’t this class an enum?  And ask: could some of the complexity of that class go away with enhanced enums?  

More information about the amber-spec-experts mailing list