JDK 12 RFR of JDK-8173730: Stop including enhanced for-loop tip for enum values() method
Tagir Valeev
amaembo at gmail.com
Tue Sep 25 00:06:57 UTC 2018
Hello!
Sorry for stupid question, but what is modern alternative to iterate over
the enum values?
With best regards,
Tagir Valeev
вт, 25 сент. 2018 г., 4:48 joe darcy <joe.darcy at oracle.com>:
> Hello,
>
> Since enum types were added in JDK 5, which shipped GA in 2004, the
> javadoc for the compiler-generated static values() method for enums has
> stated:
>
> > Returns an array containing the constants of this enum type, in the
> > order they are declared. This method may be used to iterate over the
> > constants as follows:
> >
> > for (RoundingMode c : RoundingMode.values())
> > System.out.println(c);
>
> While the tip to use the enhanced for loop to iterate over the constants
> of the enum type may have been reasonable to include in 2004, IMO it is
> unnecessary and clutter in 2018. Therefore, please review the changes for
>
> JDK-8173730: Stop including enhanced for-loop tip for enum values()
> method
> http://cr.openjdk.java.net/~darcy/8173730.0/
>
> to remove the generation of the for loop tip.
>
> Patch below.
>
> Docs builds complete successfully and elides the tip as expected.
>
> Thanks,
>
> -Joe
>
> ---
> old/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties
>
> 2018-09-24 14:31:57.943000000 -0700
> +++
> new/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties
>
> 2018-09-24 14:31:57.771000000 -0700
> @@ -230,12 +230,7 @@
> #Documentation for Enums
> doclet.enum_values_doc.fullbody=\
> Returns an array containing the constants of this enum type, in\n\
> - the order they are declared. This method may be used to iterate\n\
> - over the constants as follows:\n\
> - <pre>\n\
> - for ({0} c : {0}.values())\n\
> - System.out.println(c);\n\
> - </pre>
> + the order they are declared.
>
> doclet.enum_values_doc.return=\
> an array containing the constants of this enum type, in the order they
> are declared
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20180925/bdb2099a/attachment.html>
More information about the compiler-dev
mailing list