enhanced enums - back from the dead?
Kevin Bourrillion
kevinb at google.com
Wed Dec 5 19:26:44 UTC 2018
On Wed, Dec 5, 2018 at 8:19 AM Maurizio Cimadamore <
maurizio.cimadamore at oracle.com> wrote:
* Our proposed treatment for generic enums raises an additional, more
> philosophical, question: what are raw types *for* and how happy are we
> in seeing more of them (in the form of raw enum types)?
>
I have looked high and low for valid use cases for raw types (apart from
interacting with legacy code), and only ever found... two.
1. As the stepping stone to make a forbidden cast:
@SuppressWarnings("unchecked") // safe because runtime type is functionally
covariant
Iterator<Object> objects = (Iterator) strings;
A common use case for this is to interact with APIs that forgot their
wlidcards, but there are plenty of other cases that can't be "fixed".
2. As the argument to instanceof. Everyone does it, of course, because
writing out `instanceof Map<?, ?>` serves no purpose.
Thankfully, they're both harmless... and I believe (?) they were even made
exempt from "rawtypes" warnings. (If not, I'd opine that they should be.)
--
Kevin Bourrillion | Java Librarian | Google, Inc. | kevinb at google.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20181205/73e9e876/attachment.html>
More information about the amber-spec-experts
mailing list