jmx-dev RFR: 8274318: Replace 'for' cycles with iterator with enhanced-for in java.management
Serguei Spitsyn
sspitsyn at openjdk.java.net
Thu Sep 30 09:48:33 UTC 2021
On Sat, 25 Sep 2021 10:51:12 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:
> There are a few places in code, where manual `for` loop is used with Iterator to iterate over Collection.
> Instead of manual `for` cycles, it's preferred to use enhanced-for cycle instead: it's less verbose, makes code easier to read and it's less error-prone.
> It doesn't have any performance impact: javac compiler generates similar code when compiling enhanced-for cycle.
> Similar cleanups:
> 1. [JDK-8274016](https://bugs.openjdk.java.net/browse/JDK-8274016) java.desktop
> 2. [JDK-8274237](https://bugs.openjdk.java.net/browse/JDK-8274237) java.base
> 3. [JDK-8274261](https://bugs.openjdk.java.net/browse/JDK-8274261) jdk.jcmd
Andrey,
I've inlined one formatting nit.
Other than that it looks good.
Thanks,
Serguei
src/java.management/share/classes/javax/management/relation/RoleResult.java line 200:
> 198: RoleUnresolved currRoleUnres = (RoleUnresolved) o;
> 199: unresolvedRoleList.add((RoleUnresolved) currRoleUnres.clone());
> 200: }
Space is not needed after casts above at lines: 176-177, 198-199.
-------------
Marked as reviewed by sspitsyn (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/5695
More information about the jmx-dev
mailing list