On Wed, 14 May 2025 18:34:40 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:
> I respectfully disagree for a few reasons: > > > NullPointerException, on the other hand, indicates the code accessed an > > object but the reference was null. (This could occur, for example, if > > parameters aren't validated.) > > Implementation and documentation of Objects.requireNonNull including its use > in our codebase and in newly added code suggests that it is intended for > validating parameters before dereferencing them. This contradicts the strict > separation you're implying. > > Additionally as I mentioned earlier the javax.sound.** code already uses npe > for null parameter checks. Introducing a mix of exception styles would reduce > consistency. The verbiage on those "sub" packages says it applies to those sub-packages not others. Moreover it was not there in the original Java Sound API docs. There was no "careful thought" given to NPE being the way to do things. It was added to avoid having to explicitly retroactively specify @throws NPE on however many methods didn't actually declare it in their spec and "accidentally" threw NPE. So not a design practice to follow. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/24991#discussion_r2093526197