RFR: do not generate null checks for record patterns
Vicente Romero
vromero at openjdk.org
Tue Jan 13 19:51:07 UTC 2026
On Sun, 11 Jan 2026 03:13:16 GMT, Vicente Romero <vromero at openjdk.org> wrote:
> do not generate null checks for record patterns
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/NullChecksWriter.java line 170:
> 168: public void visitLetExpr(LetExpr tree) {
> 169: // don't recurse inside let expressions, they are backend artifacts
> 170: result = tree;
offline suggestion from Jan Lahoda:
this code will skip all let expressions which is too broad, as let expressions are generated also by switch expressions but could contain user code. For example there is no null check generated in this case:
void main() {
int i = switch (new Object()) {
default -> {
Object obj = null;
Object! nonNull = obj;
yield 0;
}
};
}
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/1884#discussion_r2687884486
More information about the valhalla-dev
mailing list