JDK-8300691 - final variables in for loop headers should accept updates
Archie Cobbs
archie.cobbs at gmail.com
Wed Sep 11 15:05:05 UTC 2024
Hi Robbe,
On Wed, Sep 11, 2024 at 12:09 AM Robbe Pincket <robbepincket at live.be> wrote:
> If we just add a clause in 4.12.4 that says that if the variable is
> declared in a for loop header and appears as the left side of an assignment
> or compound assignment or as the argument of a postfix/prefix
> increment/decrement operator, it isn't considered to be a constant variable.
>
> I don't think that this breaks any existing code. As (non-blank) final
> variables can't appear in those locations.
>
Agreed... that's what I'm calling the "spooky action at a distance"
approach.
Although it's less graceful from a spec point of view, practically speaking
it's probably the only acceptable solution because the alternative would
break existing code (in a very narrow corner case).
-Archie
--
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20240911/117d0b5e/attachment-0001.htm>
More information about the amber-dev
mailing list