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.

One strange thing I also noticed is static field 
`sun.tools.jstat.Parser#reservedWords`, which filled in `Parser` constructor. 
Reworked to initialize it once.

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

Commit messages:
 - [PATCH] Use enhanced-for instead of plain 'for' in jdk.jcmd

Changes: https://git.openjdk.java.net/jdk/pull/5673/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=5673&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8274261
  Stats: 44 lines in 6 files changed: 0 ins; 14 del; 30 mod
  Patch: https://git.openjdk.java.net/jdk/pull/5673.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/5673/head:pull/5673

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

Reply via email to