On Tue, 23 Sep 2025 17:58:13 GMT, Alan Bateman <[email protected]> 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

Reply via email to