RFR: 8372635: Lambdas do not copy over SYNTHETIC flag for local variables
Jan Lahoda
jlahoda at openjdk.org
Tue Dec 9 15:13:21 UTC 2025
Consider case like:
Object o = ...;
//synthetic variable for the instanceof's expression
boolean b = o.toString() instanceof String str && str.isEmpty();
Runnable r = () -> {
//synthetic variable for the instanceof's expression
boolean b = o.toString() instanceof String str && str.isEmpty();
};
There are synthetic variables generated for `o.toString()`, to ensure the method is invoked only once for each `instanceof`. These variables are marked as synthetic in `TransPatterns` (and then consequently omitted in `LocalVariableTable`), but when the flag is lost for the variable in the lambda.
This PR proposes to keep the flag, as suggested in the bug.
-------------
Commit messages:
- 8372635: Lambdas do not copy over SYNTHETIC flag for local variables
Changes: https://git.openjdk.org/jdk/pull/28724/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28724&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8372635
Stats: 139 lines in 2 files changed: 138 ins; 0 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/28724.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/28724/head:pull/28724
PR: https://git.openjdk.org/jdk/pull/28724
More information about the compiler-dev
mailing list