RFR: 8375119: SwitchBoostraps.enumSwitch does not throw an NPE when lookup is null in some cases

Johannes Döbler duke at openjdk.org
Tue Jan 13 20:50:57 UTC 2026


On Tue, 13 Jan 2026 18:05:43 GMT, Jan Lahoda <jlahoda at openjdk.org> 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.

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

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


More information about the core-libs-dev mailing list