Skip to content

8298380: Clean up redundant array length checks in JDK code base#11589

Closed
stsypanov wants to merge 1 commit intoopenjdk:masterfrom
stsypanov:8298380
Closed

8298380: Clean up redundant array length checks in JDK code base#11589
stsypanov wants to merge 1 commit intoopenjdk:masterfrom
stsypanov:8298380

Conversation

@stsypanov
Copy link
Contributor

@stsypanov stsypanov commented Dec 8, 2022

Newer version of IntelliJ IDEA introduces new inspection detecting redundant array length check in snippets like

<T> void iterate(T[] items) {
  if (items.length == 0) {
    return;
  }
  for (T item : items) {
    //...
  }
}

Here

if (items.length == 0) {
  return;
}

is redundant and can be removed as length check is performed by for-each loop.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8298380: Clean up redundant array length checks in JDK code base

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/11589/head:pull/11589
$ git checkout pull/11589

Update a local copy of the PR:
$ git checkout pull/11589
$ git pull https://git.openjdk.org/jdk pull/11589/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11589

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/11589.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 8, 2022

👋 Welcome back stsypanov! 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.

@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 8, 2022
@openjdk
Copy link

openjdk bot commented Dec 8, 2022

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

  • client
  • core-libs
  • hotspot-compiler
  • nio
  • 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 nio nio-dev@openjdk.org hotspot-compiler hotspot-compiler-dev@openjdk.org client client-libs-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels Dec 8, 2022
@mlbridge
Copy link

mlbridge bot commented Dec 8, 2022

Webrevs

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These all seem fine to me.

You can count this as the review for hotspot and serviceability. :)

@openjdk
Copy link

openjdk bot commented Dec 9, 2022

@stsypanov 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:

8298380: Clean up redundant array length checks in JDK code base

Reviewed-by: dholmes, amenkov, serb, vtewari

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 13 new commits pushed to the master branch:

  • 11aece2: 8257197: Add additional verification code to PhaseCCP
  • 7f9c6ce: 8297679: InvocationTargetException field named target is not declared final
  • 5540a8c: 8298083: The "CheckBox/RadioButton[Enabled/Disabled].textForeground" stoped working
  • c16eb89: 8298138: Shenandoah: HdrSeq asserts "sub-bucket index (512) overflow for value ( 1.00)"
  • 3dfadee: 8292289: [vectorapi] Improve the implementation of VectorTestNode
  • d35e840: 8297295: Remove ThreadGroup.allowThreadSuspension
  • 175e3d3: 8296149: Start of release updates for JDK 21
  • d562d3f: 8297642: PhaseIdealLoop::only_has_infinite_loops must detect all loops that never lead to termination
  • fc52f21: 8298255: JFR provide information about dynamization of number of compiler threads
  • e555d54: 8298383: JFR: GenerateJfrFiles.java lacks copyright header
  • ... and 3 more: https://git.openjdk.org/jdk/compare/fbe7b007383b034589e93d398706bebeb24461ee...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 (@dholmes-ora, @alexmenkov, @mrserb, @vyommani) 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 Dec 9, 2022
Copy link
Member

@mrserb mrserb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "client" changes in src/java.desktop looks fine

Copy link
Contributor

@vyommani vyommani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

java.base changes looks ok to me.

@stsypanov
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Dec 9, 2022
@openjdk
Copy link

openjdk bot commented Dec 9, 2022

@stsypanov
Your change (at version eb45211) is now ready to be sponsored by a Committer.

@TheShermanTanker
Copy link
Contributor

/sponsor

@openjdk
Copy link

openjdk bot commented Dec 9, 2022

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

  • 33d955a: 8298345: Fix another two C2 IR matching tests for RISC-V
  • cb766c5: 8297778: Modernize and improve module jdk.sctp
  • 11aece2: 8257197: Add additional verification code to PhaseCCP
  • 7f9c6ce: 8297679: InvocationTargetException field named target is not declared final
  • 5540a8c: 8298083: The "CheckBox/RadioButton[Enabled/Disabled].textForeground" stoped working
  • c16eb89: 8298138: Shenandoah: HdrSeq asserts "sub-bucket index (512) overflow for value ( 1.00)"
  • 3dfadee: 8292289: [vectorapi] Improve the implementation of VectorTestNode
  • d35e840: 8297295: Remove ThreadGroup.allowThreadSuspension
  • 175e3d3: 8296149: Start of release updates for JDK 21
  • d562d3f: 8297642: PhaseIdealLoop::only_has_infinite_loops must detect all loops that never lead to termination
  • ... and 5 more: https://git.openjdk.org/jdk/compare/fbe7b007383b034589e93d398706bebeb24461ee...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Dec 9, 2022
@openjdk openjdk bot closed this Dec 9, 2022
@openjdk openjdk bot 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 Dec 9, 2022
@openjdk
Copy link

openjdk bot commented Dec 9, 2022

@TheShermanTanker @stsypanov Pushed as commit e3c6cf8.

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

@stsypanov stsypanov deleted the 8298380 branch December 9, 2022 13:26
@RogerRiggs
Copy link
Contributor

@stsypanov , @TheShermanTanker You jumped the gun a bit on the integration and sponsoring. There was no approval for the core-libs parts from a "R"eviewer.

@stsypanov
Copy link
Contributor Author

@RogerRiggs changes are trivial. Should I revert any of them?

@RogerRiggs
Copy link
Contributor

No, just a reminder to be through in the process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client client-libs-dev@openjdk.org core-libs core-libs-dev@openjdk.org hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated nio nio-dev@openjdk.org serviceability serviceability-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

7 participants