RFR: JDK-8282776: Bad NullPointerException message when invoking an interface MethodHandle on a null receiver

Mandy Chung mchung at openjdk.java.net
Thu Mar 10 19:19:38 UTC 2022


On Wed, 9 Mar 2022 22:52:41 GMT, Mandy Chung <mchung at openjdk.org> wrote:

> A simple patch to call `Objects.requireNonNull(recv)` for an explicit null receiver check rather than NPE thrown by `Object::getClass`.  The message of NPE generated by JEP 358 (Helpful NullPointerExceptions) is supposed to be helpful but not in this case.

`Objects::requireNonNull` is force inlined.   I expect the performance overhead should be insignificant in practice.   I asked @cl4es to give the performance guidance and review.

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

PR: https://git.openjdk.java.net/jdk/pull/7766


More information about the core-libs-dev mailing list