On Tue, 7 Oct 2025 15:04:47 GMT, Chen Liang <[email protected]> wrote:

>> src/java.base/share/classes/java/lang/reflect/Field.java line 982:
>> 
>>> 980:         } else {
>>> 981:             setFinal(Reflection.getCallerClass(), obj, () -> 
>>> fa.setByte(obj, b));
>>> 982:         }
>> 
>> Suggestion:
>> 
>>         if (!Modifier.isFinal(modifiers)) {
>>             fa.setByte(obj, b);
>>         } else {
>>             setFinal(Reflection.getCallerClass(), obj, () -> 
>> getOverrideFieldAccessor().setByte(obj, b));
>>         }
>
> We still need to capture `b` here so this doesn't really improve anything. 
> Same for others.

Right, and capturing fa/obj/b vs. this/obj/b is also not a concern because this 
is the slow case for final fields.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25115#discussion_r2410998983

Reply via email to