RFR: 8263380: Unintended use of Objects.nonNull in VarHandles

Claes Redestad redestad at openjdk.java.net
Wed Mar 10 16:44:06 UTC 2021


On Wed, 10 Mar 2021 16:04:59 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

> Nice catch!
> 
> We have a test that is supposed to test this: https://github.com/openjdk/jdk/blob/master/test/jdk/java/foreign/TestNulls.java But it is only checking if an NPE is thrown, and not checking for a message, since `Objects::requireNonNull` does not set an exception message. I guess that test was still passing because NPEs are thrown at some other point during the call.

Right, checked that passes (had only run the java/lang/invoke tests locally). An alternative approach here is to verify all methods already implicitly check null and remove all these, but being explicit is nice and reduces possibility of surprise.

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

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


More information about the core-libs-dev mailing list