RFR: add use site null checks for fields [v5]

Vicente Romero vromero at openjdk.org
Mon Jan 19 12:54:52 UTC 2026


On Mon, 19 Jan 2026 10:23:31 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   changes to test
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/NullChecksWriter.java line 165:
> 
>> 163:                     sym.owner.kind == TYP &&
>> 164:                     sym.kind == VAR &&
>> 165:                     !isInThisSameCompUnit(sym) &&
> 
> I note that, for fields use site checks, we're checking that the field access is pointing to a field in a different compilation unit. But for method calls use-site we don't look for this and always (for now) emit the use site check. I wonder if for now we should err on the side of always generating the checks, and then come back later and (in one shot) relax the translation strategy to omit the checks in cases where they are provably unnecessary.

we can do that or just add the same check to methods. I didn't think about this for the method's case. Seems like a very minimal `optimization` that should be there since the beginning. I could add the same for methods as part of this PR

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/1926#discussion_r2704654985


More information about the valhalla-dev mailing list