On Thu, 7 May 2026 23:04:52 GMT, Dan Smith <[email protected]> wrote:
>> src/java.base/share/classes/java/lang/Class.java line 643:
>>
>>> 641: @PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS,
>>> reflective=true)
>>> 642: public boolean isValue() {
>>> 643: return !identity && !primitive && !isInterface();
>>
>> We can update the VM representation to change `identity` injection to
>> `value` injection as a separate RFE probably for post lworld.
>
> Yeah, it's possible, but I wasn't totally sure what other components might be
> inspecting this field directly. Didn't want to rock the boat. I agree it's
> worth considering as a future refactoring.
I didn't really like injecting 'identity'. java.lang.Class can figure this
out optimally without the JVM's help.
The JVM just sets the value based on whether it's an array and the ACC_IDENTITY
access flag is set.
set_is_identity(mirror(), k->is_array_klass() || k->is_identity_class());
You could cache the answer if you'd like in a field:
value = !isArray() && getClassAccessFlags() has ACC_IDENTITY (why not in
modifiers??) && !primitive && !isInterface();
Anyways, you can check the performance and fix this later.
-------------
PR Review Comment:
https://git.openjdk.org/valhalla/pull/2397#discussion_r3205286119