RFR: 8356049: Need a simple way to play back a sound clip [v5]

Sergey Bylokhov serb at openjdk.org
Fri May 16 21:17:55 UTC 2025


On Fri, 16 May 2025 20:57:42 GMT, Phil Race <prr at openjdk.org> wrote:

>>>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.
>> 
>> No, in many cases NPE was explicitly added to many methods in that packages, even if npe had not been thrown before. It is better to use NPE. Check how many "@throws NullPointerException if XXX is {@code null}" is in that code, and compare that with usage of IllegalArgumentException.
>
>> > 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.
>> 
>> No, in many cases NPE was explicitly added to many methods in that packages, even if npe had not been thrown before. It is better to use NPE. Check how many "@throws NullPointerException if XXX is {@code null}" is in that code, and compare that with usage of IllegalArgumentException.
> 
> So even if some parts ofthe fix up did add NPE after the fact - documenting what was already happening by accident doesn't seem to support a clear design desicion or an essential need to use NPE in this case

That is not an accident, most of that API already thrown IllegalArgumentException and we could change to throw it on null as well, but the whole JavaSound api was checked and unified to throw only one NPE.

What is the point of adding an IllegalArgumentException just for that one case?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24991#discussion_r2093684901


More information about the client-libs-dev mailing list