On Wed, 2 Apr 2025 11:43:40 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> 
wrote:

>> I didn't mean to say "this is not true, so use a `static final` instead". 
>> What I meant was more "let's not dive into VM-specific details now" (see my 
>> other comment on the topic), and just focus on semantics instead. Then let's 
>> put all the constant-folding related stuff somewhere else. I liked using 
>> non-static final fields!
>
> Basically: drop all references to "performance" and "constant folding" 
> everywhere. And then introduce a section dedicated to that topic which talks 
> a bit about how the content of a SV is trusted not to change by the JVM, 
> which enables constant-folding optimizations.

The reason I'm suggesting this is that what's constant-folded is kind of a 
moving target, so we don't want to say/promise too much. For now, we can say 
that if the SV, or the stable function/collection is stored in a static/final 
field then its content will be constant-folded. But we know that there's other 
stuff in the pipeline (e.g. [this JEP](https://openjdk.org/jeps/8349536)) which 
will affect this picture, and enable for more constant-folding when accessing 
SV and stable functions/collections.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2024659484

Reply via email to