On Tue, 13 Jan 2026 20:48:52 GMT, Johannes Döbler <[email protected]> wrote:

> > The SwitchBootstraps.enumSwitch is documented to throw a 
> > NullPointerException when lookup is null, but it does not throw the 
> > exception in all cases.
> 
> Nothing against failing fast, but wouldn't this argumentation open a can of 
> worms? The method documents that it can throw multiple exceptions but there 
> is no guaranteed order of argument checking. So even if the method documents 
> that it rejects a null `labels` parameter it is still valid to throw a 
> IllegalArgumentException first when checking the `invocationType` parameter.

The point of adding the explicit checks for `invocationType` and `labels` is to 
avoid the need to analyze the code/reason about the code to find out whether 
the check is carried or not. Because even for `lookup`, the code mostly seemed 
like it will throw NPE for `lookup == null`, but it didn't. And when explicitly 
checking `lookup`, it seems weird to not explicitly check all of them.

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

PR Comment: https://git.openjdk.org/jdk/pull/29202#issuecomment-3749609146

Reply via email to