On Sat, 17 Jan 2026 01:15:22 GMT, Vicente Romero <[email protected]> wrote:
>> generate null checks for field use sites depending on a compiler option, see >> also [1] which did a similar thing for method invocations >> >> [1] https://github.com/openjdk/valhalla/pull/1910 > > 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. src/jdk.compiler/share/classes/com/sun/tools/javac/comp/NullChecksWriter.java line 179: > 177: > 178: private Symbol outermostType(Symbol sym) { > 179: Symbol prev = null; Doesn't `sym.outermostClass()` work? ------------- PR Review Comment: https://git.openjdk.org/valhalla/pull/1926#discussion_r2704143541 PR Review Comment: https://git.openjdk.org/valhalla/pull/1926#discussion_r2704135873
