RFR: 8353835: Implement JEP 500: Prepare to Make Final Mean Final [v2]
David Holmes
dholmes at openjdk.org
Tue Sep 23 22:12:15 UTC 2025
On Tue, 23 Sep 2025 17:58:13 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>>> Otherwise how can these fields be considered as "trusted finals"??
>>
>> FTR `System.in` et al are not considered as trusted finals. There's a special logic in `ciField::initialize_from()` to disable corresponding optimizations, so the fields aren't treated as constants.
>
>> I thought the ability to mutate these fields was restricted to the native implementations of setIn et al. and was not allowed via regular reflection?
>
> Right, core reflection can't modify static finals. JLS 17.5.4 labels System.in/out/err as write-protected fields that can be modified by the setIn/setOut/setErr methods. Historical and unfortunate, and works because these methods were always in JNI. The existence of these methods means the VM can't trust these fields and so has to special case them.
@AlanBateman never mind I see now this check feeds up to the JNI code.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25115#discussion_r2373563504
More information about the core-libs-dev
mailing list