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

Andrey Turbanov aturbanov at openjdk.org
Thu Mar 6 20:10:10 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.

While having prerequirements checks often is good, I think not having it in String.join can be a good thing.
1. String.join is quite short method. 11 lines. And having 2 lines to have _excessive_ check don't improve reading experience much.
2. There are other overloads which don't have null check. I personally like them more - they are easier to read.
3. `String` is one of core classes, and having a bit shorter and more performant code will never be redundant in it.

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

PR Comment: https://git.openjdk.org/jdk/pull/23710#issuecomment-2704832981


More information about the core-libs-dev mailing list