RFR: 8351344: Avoid explicit Objects.requireNonNull in String.join

Chen Liang liach at openjdk.org
Thu Mar 6 11:57:07 UTC 2025


On Thu, 20 Feb 2025 09:30:02 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

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

Looks nice to me, thanks!

src/java.base/share/classes/java/lang/String.java line 3650:

> 3648:         var delim = delimiter.toString();
> 3649:         var elems = new String[8];
> 3650:         int size = 0;

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.

-------------

Marked as reviewed by liach (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/23710#pullrequestreview-2638571708
PR Review Comment: https://git.openjdk.org/jdk/pull/23710#discussion_r1964153031


More information about the core-libs-dev mailing list