On Tue, 23 Apr 2024 12:22:25 GMT, Per Minborg <pminb...@openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/reflect/AccessibleObject.java line 193:
>> 
>>> 191:      * <li>final fields declared in a {@linkplain Class#isHidden() 
>>> hidden class}</li>
>>> 192:      * <li>final fields declared in a {@linkplain Class#isRecord() 
>>> record}</li>
>>> 193:      * <li>final fields of type {@linkplain StableValue 
>>> StableValue}</li>
>> 
>> In Valhalla, we've been looking at adding "strict" final fields to support 
>> value classes (which must be strongly immutable) which are fields that are 
>> unmodifiable.  Most of the existing unmodifiable field cases can be covered 
>> by "strict" fields.  This one can't though so I'm a little saddened to see 
>> this list grow.
>
> Maybe we could introduce a special marker interface (e.g. `TrustedFieldType`) 
> that signals this behavior. This might only take effect if loaded via the 
> boot loader.

Thinking on this more, hidden classes & records & value classes can all be 
dealt with by the introduction of strict fields.  Adding a new type - 
TrustedFieldType - when we'll eventually only have 1 type here - StableValue - 
seems like an unnecessary tradeoff.

If we ever have to add a second type here, then it's probably worth revisiting 
this idea.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18794#discussion_r1584921294

Reply via email to