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

[PATCH] Avoid explicit Objects.requireNonNull where we know implicit NPE will happen #23710

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

turbanoff
Copy link
Member

@turbanoff turbanoff commented Feb 20, 2025

We have helpful NPE messages now - they are more user-friendly.
And shorter methods are more likely to be inlined.


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

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

…NPE will happen

We have helpful NPE messages now
And shorter methods are more likely to be inlined
@bridgekeeper
Copy link

bridgekeeper bot commented Feb 20, 2025

👋 Welcome back aturbanov! 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
Copy link

openjdk bot commented Feb 20, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Feb 20, 2025

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

  • core-libs

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;
Copy link
Member

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.

Copy link
Member

@liach liach left a 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!

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

Successfully merging this pull request may close these issues.

2 participants