On Mon, 7 Sep 2026 10:54:19 GMT, Yasumasa Suenaga <[email protected]> wrote:

>> Value Object has been introduced since JDK 28 (as a preview feature), 
>> however it cannot be handled in SA.
>> 
>> 
>> public value class Test{
>> 
>>   public static value record Rec(byte recA, byte recB){};
>> 
>>   byte a;
>> 
>>   byte b;
>> 
>>   Rec rec;
>> 
>>   byte c;
>> }
>> 
>> 
>> `rec` as `Test$Rec` can be inlined into the instance of `Test`, but it would 
>> be shown as "Bad OOP" in "inspect" on SA. SA should show valid values in 
>> `rec`.
>> 
>> Note that his change would expand flattened object in below in `inspect` 
>> CLHSDB command:
>> 
>> 
>> hsdb> inspect 0xc22419e8
>> instance of Oop for LingeredAppWithValueObject$ValueObj @ 0x00000000c22419e8 
>> (size = 16)
>> _mark: 73201086130815105
>> a: 1
>> b: 2
>> rec:
>>   recA: 10
>>   recB: 20
>> c: 3
>> 
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Yasumasa Suenaga has updated the pull request with a new target base due to a 
> merge or a rebase. The pull request now contains 18 commits:
> 
>  - Rename to "Value" from "Inline"
>  - Merge branch 'master' into JDK-8390106
>  - Merge remote-tracking branch 'origin/master' into JDK-8390106
>  - Update testcase
>  - Add override methods
>  - Check null marker for value object
>  - Merge branch 'master' into JDK-8390106
>  - Update comments
>  - Add isInline()
>  - Update 
> src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/FlattenedInline.java
>    
>    Co-authored-by: Chris Plummer <[email protected]>
>  - ... and 8 more: https://git.openjdk.org/jdk/compare/4c98aa9d...932cbd82

It looks pretty good in general. I've posted a couple of comments though. Also, 
I've not reviewed the test changes yet.

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java line 
186:

> 184:       if (klass instanceof ObjArrayKlass) return new ObjArray(handle, 
> this);
> 185:       if (klass instanceof InstanceKlass) return new Instance(handle, 
> this);
> 186:       if (klass instanceof ValueKlass)    return new Value(handle, this);

I'm not sure the above line 186 is correct. Should we swap it with the line 185?
The ValueClass is a sub-class of the InstanceClass, so that the line 185 will 
always return newly constructed Instance instead of Value for any class which 
is an instance of ValueKlass.

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ValueKlass.java line 
93:

> 91:   public int nullMarkerOffset() {
> 92:     return members().nullMarkerOffset();
> 93:   }

This reads the null marker address from the ValueKlass layout unconditionally.
A null marker is needed for a nullable flattened fields.
If I understand correctly, null-restricted (non-null) flat fields may have no 
null marker.
You may want to try the function 
`InstanceKlass::field_is_null_free_inline_type(int index)`.
The function `fieldDescriptor::has_null_marker()` can be used as well.

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

PR Review: https://git.openjdk.org/jdk/pull/32310#pullrequestreview-5160918884
PR Review Comment: https://git.openjdk.org/jdk/pull/32310#discussion_r3973933792
PR Review Comment: https://git.openjdk.org/jdk/pull/32310#discussion_r3974059023

Reply via email to