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

8258422: Cleanup unnecessary null comparison before instanceof check in java.base #20

Conversation

@turbanoff
Copy link
Contributor

@turbanoff turbanoff commented Sep 5, 2020


Progress

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

Issue

  • JDK-8258422: Cleanup unnecessary null comparison before instanceof check in java.base

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/20/head:pull/20
$ git checkout pull/20

@bridgekeeper bridgekeeper bot added the oca label Sep 5, 2020
@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Sep 5, 2020

Hi @turbanoff, welcome to this OpenJDK project and thanks for contributing!

We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing /signed in a comment in this pull request.

If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user turbanoff" as summary for the issue.

If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing /covered in a comment in this pull request.

@openjdk
Copy link

@openjdk openjdk bot commented Sep 5, 2020

@turbanoff The following labels will be automatically applied to this pull request: core-libs`, `net`, `nio. 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 (add|remove) "label" command.

@turbanoff
Copy link
Contributor Author

@turbanoff turbanoff commented Sep 5, 2020

/signed

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Sep 5, 2020

Thank you! Please allow for up to two weeks to process your OCA, although it is usually done within one to two business days. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated!

@turbanoff turbanoff force-pushed the turbanoff:cleanup_null_checks_before_instanceof_in_java.base branch from 71fa52f to f09bbd2 Sep 6, 2020
@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Oct 4, 2020

@turbanoff This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@turbanoff
Copy link
Contributor Author

@turbanoff turbanoff commented Oct 4, 2020

I believe this changes is useful and still actual:

  1. improve code to make it easier to read.
  2. performance should be improved a bit too
@stuart-marks
Copy link
Member

@stuart-marks stuart-marks commented Oct 31, 2020

I’ll see if I can get somebody to take a look at this.

@ChrisHegarty
Copy link
Member

@ChrisHegarty ChrisHegarty commented Nov 2, 2020

This seems like a reasonable change, which improves readability.

My preference is to wait a little longer (hopefully no more than a couple of weeks), until JEP 394 - "Pattern Matching for instanceof" is finalised, then we can remove the explicit casts in many of these cases. For example:

+++ b/src/java.base/share/classes/java/io/File.java
@@ -2191,8 +2191,8 @@ public class File
      *          {@code false} otherwise
      */
     public boolean equals(Object obj) {
-        if ((obj != null) && (obj instanceof File)) {
-            return compareTo((File)obj) == 0;
+        if (obj instanceof File file) {
+            return compareTo(file) == 0;
         }
         return false;
     }
@turbanoff
Copy link
Contributor Author

@turbanoff turbanoff commented Dec 2, 2020

@AlekseiEfimov
Copy link
Member

@AlekseiEfimov AlekseiEfimov commented Dec 15, 2020

Hi @turbanoff,

I've logged a JBS issue for tracking this change:
https://bugs.openjdk.java.net/browse/JDK-8258422

JEP 394 is finalized now, so I guess you could follow-up Chris suggestion to remove the explicit casts.

After the fix is properly reviewed and marked as ready for the integration (you'll need to issue /integrate command), once it is done I would happily /sponsor the change.

With Best Regards,
Aleksei

@AlekseiEfimov
Copy link
Member

@AlekseiEfimov AlekseiEfimov commented Dec 15, 2020

/issue JDK-8258422

@openjdk
Copy link

@openjdk openjdk bot commented Dec 15, 2020

@AlekseiEfimov Only the author (@turbanoff) is allowed to issue the /issue command.

@turbanoff
Copy link
Contributor Author

@turbanoff turbanoff commented Dec 15, 2020

/issue JDK-8258422

@openjdk openjdk bot changed the title [PATCH] Cleanup unnecessary null comparison before instanceof check 8258422: Cleanup unnecessary null comparison before instanceof check in java.base Dec 15, 2020
@openjdk
Copy link

@openjdk openjdk bot commented Dec 15, 2020

@turbanoff The primary solved issue for a PR is set through the PR title. Since the current title does not contain an issue reference, it will now be updated.

@openjdk openjdk bot added the rfr label Dec 15, 2020
@mlbridge
Copy link

@mlbridge mlbridge bot commented Dec 15, 2020

@turbanoff turbanoff force-pushed the turbanoff:cleanup_null_checks_before_instanceof_in_java.base branch from f09bbd2 to 603cd36 Dec 15, 2020
…in java.base

use instanceof pattern matching in UnixPath too
@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

28 similar comments
@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 2021

@AlekseiEfimov The command sponsor can only be used in open pull requests.

cushon pushed a commit to cushon/jdk that referenced this pull request Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment