RFR: add use site null checks

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Jan 15 10:01:58 UTC 2026


On Thu, 15 Jan 2026 05:46:52 GMT, Vicente Romero <vromero at openjdk.org> wrote:

> Adding use site null checks for method invocations. They are added by default but if option: `noUseSiteNullChecks` is passed, the compiler won't generate them

test/langtools/tools/javac/nullability/RuntimeNullChecks.java line 222:

> 220:                 """
> 221:                 class Test {
> 222:                     class Inner {

All these tests are trying inner classes. That said, I don't think these invocation will actually have an "interesting" external type. In fact, I believe to test `externalType` you need to have constructor calls, as that's the primary case where we add prefix parameters.

Also, there's no test for varargs calls. I suggest to add:

* method call
* constructor call/plain
* constructor call/inner

And, for all these, we should have a varargs and non-varargs flavors. Maybe this needs its own test?

(as I write this I realize that, while for methods you can use override to test use site checks, for constructor calls you can't -- you need a separate compilation test there, I think)

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/1910#discussion_r2693725642


More information about the valhalla-dev mailing list