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

8263358: Update java.lang to use instanceof pattern variable #2913

Closed
wants to merge 9 commits into from

Conversation

@pconcannon
Copy link
Contributor

@pconcannon pconcannon commented Mar 10, 2021

Hi,

Could someone please review my code for updating the code in the java.lang package to make use of the instanceof pattern variable?

Kind regards,
Patrick


Progress

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

Issue

  • JDK-8263358: Update java.lang to use instanceof pattern variable

Reviewers

Download

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

To update a local copy of the PR:
$ git checkout pull/2913
$ git pull https://git.openjdk.java.net/jdk pull/2913/head

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Mar 10, 2021

👋 Welcome back pconcannon! 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 label Mar 10, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Mar 10, 2021

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

  • core-libs
  • hotspot-compiler

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.

@mlbridge
Copy link

@mlbridge mlbridge bot commented Mar 10, 2021

@mlbridge
Copy link

@mlbridge mlbridge bot commented Mar 10, 2021

Mailing list message from Brian Goetz on hotspot-compiler-dev:

These patches are obviously minimally correct.? However, for equals
methods at least, I would take them one step further, from:

??????????? if (!(o instanceof Key that)) return false;
??????????? //noinspection StringEquality (guaranteed interned String(s))
??????????? return name == that.name &&
?????????????????? Arrays.equals(ptypes, that.ptypes);

to

??? return (o instanceof Key that)
??????? && name == that.name
??????? && Arrays.equals(ptypes, that.ptypes);

The use of "if it's not, return false" is a holdover from when we
couldn't express this as a single expression (which is almost always
preferable), which means we had to fall back to control flow.? Now we
don't have to.

On 3/10/2021 8:04 AM, Patrick Concannon wrote:

@cl4es
Copy link
Member

@cl4es cl4es commented Mar 10, 2021

Great. I included some of these in #2300 - @mlchung has asked me to split out some of the changes in that PR to make them more focused and easier to review, so I'll just go ahead and remove the things you're patching up here.

cl4es added a commit to cl4es/jdk that referenced this issue Mar 10, 2021
@pconcannon
Copy link
Contributor Author

@pconcannon pconcannon commented Mar 11, 2021

Mailing list message from Brian Goetz on hotspot-compiler-dev:

These patches are obviously minimally correct.? However, for equals
methods at least, I would take them one step further, from:

??????????? if (!(o instanceof Key that)) return false;
??????????? //noinspection StringEquality (guaranteed interned String(s))
??????????? return name == that.name &&
?????????????????? Arrays.equals(ptypes, that.ptypes);

to

??? return (o instanceof Key that)
??????? && name == that.name
??????? && Arrays.equals(ptypes, that.ptypes);

The use of "if it's not, return false" is a holdover from when we
couldn't express this as a single expression (which is almost always
preferable), which means we had to fall back to control flow.? Now we
don't have to.

On 3/10/2021 8:04 AM, Patrick Concannon wrote:

Thanks for the suggestion, Brian. I've done this now and it can be viewed in commit e9d9131

@openjdk
Copy link

@openjdk openjdk bot commented Mar 11, 2021

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

8263358: Update java.lang to use instanceof pattern variable

Reviewed-by: iris, chegar, mchung, 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 6 new commits pushed to the master branch:

  • f62b100: 8263895: Test nsk/jvmti/GetThreadGroupChildren/getthrdgrpchld001/getthrdgrpchld001.cpp uses incorrect indices
  • f84b52b: 8263897: compiler/c2/aarch64/TestVolatilesSerial.java failed with "java.lang.RuntimeException: Wrong method"
  • f08bf4b: 8263891: Changes for 8076985 missed the fix.
  • b2df513: 8261785: Calling "main" method in anonymous nested class crashes the JVM
  • 840ab7b: 8263894: Convert defaultPrinter and printers fields to local variables
  • ba504fc: 8187450: JNI local refs exceeds capacity warning in NetworkInterface::getAll

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Mar 11, 2021
dfuch
dfuch approved these changes Mar 22, 2021
Copy link
Member

@dfuch dfuch left a comment

The new changes look good to me.

@pconcannon
Copy link
Contributor Author

@pconcannon pconcannon commented Mar 24, 2021

/integrate

@openjdk openjdk bot closed this Mar 24, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Mar 24, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Mar 24, 2021

@pconcannon Since your change was applied there have been 49 commits pushed to the master branch:

  • ae9af57: 8264001: JFR: Modernize implementation
  • fad8484: 8263411: Convert jshell tool to use Stream.toList()
  • 06d46d6: 8264008: Incorrect metaspace statistics after JEP 387 when UseCompressedClassPointers is off
  • 45e1bab: 8264091: Use the blessed modifier order in java.logging
  • cb776ed: 8263981: java.awt.image.ComponentSampleModel equals/hashcode use numBands twice
  • da512bf: 8264050: Remove unused field VM_HeapWalkOperation::_collecting_heap_roots
  • 6e3a158: 8263352: assert(use == polladr) failed: the use should be a safepoint polling
  • 8d63bb6: 8260565: JFR: Fix copyright header in tests
  • 0b2aa1b: 8263978: Clarify why 0 argument is ignored in SecureRandom::setSeed
  • 15bcf6d: 8264055: backout JDK-8248904 in order to resubmit with additional attribution.
  • ... and 39 more: https://git.openjdk.java.net/jdk/compare/0abbfb2fc5ad520673c230c273477152c52e1b2c...master

Your commit was automatically rebased without conflicts.

Pushed as commit 329697b.

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

@pconcannon pconcannon deleted the JDK-8263358 branch May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment