RFR: 8274395: Use enhanced-for instead of plain 'for' in jdk.internal.jvmstat

Chris Plummer cjplummer at openjdk.java.net
Mon Sep 27 21:40:13 UTC 2021


On Mon, 20 Sep 2021 08:15:13 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:

> There are few places in code where manual `for` loop is used with Iterator to iterate over Collection or Array.
> 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
> 4. [JDK-8274318](https://bugs.openjdk.java.net/browse/JDK-8274318) java.management

You need a copyright update in TypeCode.java. Otherwise the changes look good.

-------------

Marked as reviewed by cjplummer (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/5580


More information about the serviceability-dev mailing list