-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[PATCH] Avoid explicit Objects.requireNonNull where we know implicit NPE will happen #23710
base: master
Are you sure you want to change the base?
Conversation
…NPE will happen We have helpful NPE messages now And shorter methods are more likely to be inlined
👋 Welcome back aturbanov! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@turbanoff The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
@@ -3645,8 +3645,6 @@ static String join(String prefix, String suffix, String delimiter, String[] elem | |||
*/ | |||
public static String join(CharSequence delimiter, | |||
Iterable<? extends CharSequence> elements) { | |||
Objects.requireNonNull(delimiter); | |||
Objects.requireNonNull(elements); | |||
var delim = delimiter.toString(); | |||
var elems = new String[8]; | |||
int size = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a // implicit null check
before the loop? Otherwise, the null check may be forgotten that future code change may early return before the null check here is triggered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice to me, thanks!
We have helpful NPE messages now - they are more user-friendly.
And shorter methods are more likely to be inlined.
Progress
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/23710/head:pull/23710
$ git checkout pull/23710
Update a local copy of the PR:
$ git checkout pull/23710
$ git pull https://git.openjdk.org/jdk.git pull/23710/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 23710
View PR using the GUI difftool:
$ git pr show -t 23710
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/23710.diff