RFR: 8372635: Lambdas do not copy over SYNTHETIC flag for local variables
Chen Liang
liach at openjdk.org
Wed Dec 10 15:00:07 UTC 2025
On Wed, 10 Dec 2025 14:38:46 GMT, covers1624 <duke at openjdk.org> wrote:
>> Exactly - this code should copy the specified flags, if they are set. I.e. if the original variable is not synthetic, the new one won't be synthetic either. If the original variable is synthetic, the flag will be transferred to the new variable.
>>
>> Given the handling of local variables and parameters is slightly different, I am not sure unifying the flags manipulation is quite feasible.
>
> Hi, I was the one who found this bug and filed it via @sciwhiz12 on the issue tracker.
>
> I was a bit confused by these flags, and didn't dig deep enough, but I'm not overly sure why these aren't just preserved as-is. Considering these are all Javac internal flags, my knowledge here is limited.
>
> Are there any flags applicable to locals that shouldn't be copied when lowering lambdas?
The `& FINAL` mask seems to be originally from [JDK-8026749](https://bugs.openjdk.org/browse/JDK-8026749) ([commit](https://github.com/openjdk/jdk/commit/cf30c203379008ebae37bf00f1839a69cd53ca26)). That patch just aimed to create an LVT for debugger and did not copy over any flag, and incorrectly set the final flag which was subsequently fixed.
I don't know why the original patch did not pass over all flags. Maybe it was limited to debugger support and never anticipated actual use of these variables' flags. Yet I don't see a reason in the original issue for not reusing the flags.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28724#discussion_r2606998563
More information about the compiler-dev
mailing list