On Tue, 22 Mar 2022 17:55:13 GMT, Mandy Chung <mch...@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. > > Mandy Chung has updated the pull request incrementally with one additional > commit since the last revision: > > Add exception message This needs to use `String.format(…)` in order to avoid circular dependencies in bootstraps on `java.lang.invoke.StringConcatFactory`. src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java line 424: > 422: throw new IncompatibleClassChangeError(msg); > 423: } else { > 424: throw new NullPointerException("Cannot invoke " + > member + " with null receiver"); Suggestion: String msg = String.format("Cannot invoke %s with null receiver", member); throw new NullPointerException(msg); src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java line 456: > 454: throw new IncompatibleClassChangeError(msg); > 455: } else { > 456: throw new NullPointerException("Cannot invoke " + > member + " with null receiver"); Suggestion: String msg = String.format("Cannot invoke %s with null receiver", member); throw new NullPointerException(msg); ------------- PR: https://git.openjdk.java.net/jdk/pull/7766