JDK-8300691 - final variables in for loop headers should accept updates

Archie Cobbs archie.cobbs at gmail.com
Wed Dec 11 19:33:21 UTC 2024


Thanks for the comments.

On Tue, Dec 10, 2024 at 8:44 PM David Alayachew <davidalayachew at gmail.com>
wrote:

> The entire reason that this feature is being considered is because WE KNOW
> that we are being safe, but the compiler doesn't have enough info to know.
>

I think it's more subtle than that... the compiler often does have enough
information, but there are some other reasons trying to extend this to all
"quiescent" variables would be tricky.

One issue is that the JLS doesn't talk about variables being captured &
duplicated - even though we know that's what actually happens in practice.
In the JLS there's only one variable. Therefore, any JLS change that
forcibly "reveals the truth" would be pretty disruptive (an example is the
simple rule "allow capture anywhere"). See previous discussions in this
thread for details.

FYI I'll also ask my question on amber-spec-experts to get their opinion.

Thanks,
-Archie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20241211/100518f2/attachment.htm>


More information about the amber-dev mailing list