Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8274318: Replace 'for' cycles with iterator with enhanced-for in java.management #5695

Conversation

turbanoff
Copy link
Member

@turbanoff turbanoff commented Sep 25, 2021

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 java.desktop
  2. JDK-8274237 java.base
  3. JDK-8274261 jdk.jcmd

Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8274318: Replace 'for' cycles with iterator with enhanced-for in java.management

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5695/head:pull/5695
$ git checkout pull/5695

Update a local copy of the PR:
$ git checkout pull/5695
$ git pull https://git.openjdk.java.net/jdk pull/5695/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5695

View PR using the GUI difftool:
$ git pr show -t 5695

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5695.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 25, 2021

👋 Welcome back turbanoff! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@turbanoff turbanoff changed the title [PATCH] Use enhanced-for instead of plain 'for' in java.management 8274318: Replace 'for' cycles with iterator with enhanced-for in java.management Sep 25, 2021
@openjdk
Copy link

openjdk bot commented Sep 25, 2021

@turbanoff The following labels will be automatically applied to this pull request:

  • jmx
  • serviceability

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org jmx jmx-dev@openjdk.org rfr Pull request is ready for review labels Sep 25, 2021
@mlbridge
Copy link

mlbridge bot commented Sep 25, 2021

Webrevs

@openjdk
Copy link

openjdk bot commented Sep 27, 2021

@turbanoff This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8274318: Replace 'for' cycles with iterator with enhanced-for in java.management

Reviewed-by: cjplummer, sspitsyn, dfuchs

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 134 new commits pushed to the master branch:

  • 754bc82: 8274525: Replace uses of StringBuffer with StringBuilder in java.xml
  • 4e7d7ca: 8273711: Remove redundant stream() call before forEach in jdk.jlink
  • f3cedbe: 8274464: Remove redundant stream() call before forEach in java.* modules
  • c10de35: 8262944: Improve exception message when automatic module lists provider class not in JAR file
  • b8af6a9: 8273917: Remove 'leaf' ranking for Mutex
  • c80a612: 8273381: Assert in PtrQueueBufferAllocatorTest.stress_free_list_allocator_vm
  • 9759fcb: 8274496: Use String.contains() instead of String.indexOf() in java.desktop
  • cdf8930: 8274625: Search field placeholder behavior
  • df125f6: 8273410: IR verification framework fails with "Should find method name in validIrRulesMap"
  • c74726d: 8274730: AArch64: AES/GCM acceleration is broken by the fix for JDK-8273297
  • ... and 124 more: https://git.openjdk.java.net/jdk/compare/5756385c2bb106917f45ba71b24cf1645f702ebf...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@plummercj, @sspitsyn, @dfuch) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 27, 2021
Copy link
Contributor

@sspitsyn sspitsyn left a comment

Andrey,
I've inlined one formatting nit.
Other than that it looks good.
Thanks,
Serguei

@turbanoff
Copy link
Member Author

turbanoff commented Oct 1, 2021

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Oct 1, 2021
@openjdk
Copy link

openjdk bot commented Oct 1, 2021

@turbanoff
Your change (at version 263e868) is now ready to be sponsored by a Committer.

Copy link
Contributor

@sspitsyn sspitsyn left a comment

Thank you for the update. It looks good.
Thanks,
Serguei

dfuch
dfuch approved these changes Oct 6, 2021
@dfuch
Copy link
Member

dfuch commented Oct 6, 2021

/sponsor

@openjdk
Copy link

openjdk bot commented Oct 6, 2021

Going to push as commit 9945f7a.
Since your change was applied there have been 134 commits pushed to the master branch:

  • 754bc82: 8274525: Replace uses of StringBuffer with StringBuilder in java.xml
  • 4e7d7ca: 8273711: Remove redundant stream() call before forEach in jdk.jlink
  • f3cedbe: 8274464: Remove redundant stream() call before forEach in java.* modules
  • c10de35: 8262944: Improve exception message when automatic module lists provider class not in JAR file
  • b8af6a9: 8273917: Remove 'leaf' ranking for Mutex
  • c80a612: 8273381: Assert in PtrQueueBufferAllocatorTest.stress_free_list_allocator_vm
  • 9759fcb: 8274496: Use String.contains() instead of String.indexOf() in java.desktop
  • cdf8930: 8274625: Search field placeholder behavior
  • df125f6: 8273410: IR verification framework fails with "Should find method name in validIrRulesMap"
  • c74726d: 8274730: AArch64: AES/GCM acceleration is broken by the fix for JDK-8273297
  • ... and 124 more: https://git.openjdk.java.net/jdk/compare/5756385c2bb106917f45ba71b24cf1645f702ebf...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Oct 6, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Oct 6, 2021
@openjdk
Copy link

openjdk bot commented Oct 6, 2021

@dfuch @turbanoff Pushed as commit 9945f7a.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@turbanoff turbanoff deleted the cleanup_use_enhanced-for_in_java.management branch Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated jmx jmx-dev@openjdk.org serviceability serviceability-dev@openjdk.org
4 participants