RFR: 8274237: Replace 'for' cycles with iterator with enhanced-for in java.base

Weijun Wang weijun at openjdk.java.net
Fri Sep 24 13:37:52 UTC 2021


On Thu, 23 Sep 2021 20:42:48 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.
> 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.
> Sometimes we even don't need cycle at all: we can just create one ArrayList as a copy of another.
> It doesn't have any performance impact: java compiler generates similar code when compiling enhanced-for cycle.
> This is continuation of [JDK-8273261](https://bugs.openjdk.java.net/browse/JDK-8273261)

Changes in the 3 security-related files also look fine. Thanks.

I've also added a `noreg-cleanup` label to the JBS bug.

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

Marked as reviewed by weijun (Reviewer).

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


More information about the security-dev mailing list