RFR: 8372696: Allow boot classes to explicitly opt-in for final field trusting
Alan Bateman
alanb at openjdk.org
Fri Nov 28 10:59:48 UTC 2025
On Thu, 27 Nov 2025 19:08:40 GMT, Chen Liang <liach at openjdk.org> wrote:
>> src/hotspot/share/ci/ciField.cpp line 220:
>>
>>> 218: return false;
>>> 219: // Explicit opt-in from system classes
>>> 220: if (holder->trust_final_fields())
>>
>> This is definitely nicer than listing specific classes. It would be nicer again once we can make this exceptions go away.
>
> True, this occupies one of the 16 precious instance klass bits in runtime. I wish we can derive this from our final means final restrictions, but their setup is to permit use-sites to migrate more easily, and is harder for declaration sites to deduce if a declaration is easier to be permitted. We can consider blanket-trust when the JVM uses `--illegal-final-field-mutation=deny` without additional `--enable-final-field-mutation`.
This would be the equivalent of running with -XX:+TrustFinalNonStaticFields, which would be nice, but there would be performance surprises as soon as you enable final field mutation for any module (and likely ALL-UNNAMED).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28540#discussion_r2571272623
More information about the hotspot-dev
mailing list