On Wed, 17 Jun 2026 13:01:34 GMT, Chen Liang <[email protected]> wrote:

>> Right, but are `isStrictInit` and `isTrustedFinalField` equivalent now? The 
>> latter also seems to include non-strict `static final` fields for instance. 
>> 
>> The latter is set by the VM when resolving the member name based on the 
>> criteria at 
>> [1](https://github.com/openjdk/valhalla/blob/ce9ae1864dd19e0dd88ba2b65e8828936df01508/src/hotspot/share/runtime/fieldDescriptor.cpp#L46).
>> 
>> Shouldn't it be:
>> 
>> 
>> boolean noWriting = f.isFinal() && (!trusted || f.isStrictInit() || 
>> f.isTrustedFinalField());
>> 
>> 
>> This would exclude `IMPL_LOOKUP` from creating var handles that can write to 
>> trusted finals as it does now.
>> 
>> `MethodHandles::unreflectField` also still uses `isTrustedFinalField`.
>
> No, `isTrustedFinalField` never includes strict fields. It is a blanket flag 
> set by the VM for record/hidden class fields, but that doesn't respect the 
> ciField package trusting, and thus is only a partial filter.

I gave it a try, and with this patch `IMPL_LOOKUP` can create var handles that 
can write to `static final` fields, whereas with the current `lworld` code it 
fails with an `UnsupportedOperationException`. This seems like an unintended 
change.

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

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2550#discussion_r3428592240

Reply via email to