JDK-8300691 - final variables in for loop headers should accept updates
Archie Cobbs
archie.cobbs at gmail.com
Thu Sep 12 22:29:37 UTC 2024
FYI, I've created a draft PR prototyping this, using the "spooky action at
a distance" approach.
https://github.com/openjdk/jdk/pull/20976
-Archie
On Wed, Sep 11, 2024 at 10:05 AM Archie Cobbs <archie.cobbs at gmail.com>
wrote:
> 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 L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20240912/86b4fd52/attachment.htm>
More information about the amber-dev
mailing list