On Wed, 17 Jun 2026 12:47:15 GMT, Jorn Vernee <[email protected]> wrote:

>> No, I moved this check to the beginning of `VarHandles.makeFieldHandle` so 
>> IMPL_LOOKUP cannot create strict-final writing VarHandle instances:
>> 
>> 
>> boolean noWriting = f.isFinal() && (!trusted || f.isStrictInit());
>
> 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.

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

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

Reply via email to