On Thu, 13 Aug 2026 12:21:16 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 incrementally with one 
> additional commit since the last revision:
> 
>   Refactoring

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Inline.java line 37:

> 35: 
> 36: public class Inline extends Instance {
> 37: 

I think a comment here is needed that explains that instances of this class can 
be used to represent instances of a class that is inline-able (InlineKlass), 
both flattened instances and heap instances.

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Inline.java line 53:

> 51:         super(handle, heap);
> 52:         this.klass = klass;
> 53:         isFlattened = klass != null; // Assumes this instance is 
> flattened if klass is passed.

Is klass ever nulll? Seems that it is something that we should assert here, and 
just always set isFlattened to true.

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/OopField.java line 68:

> 66:     var heap = obj.getHeap();
> 67:     return isFlat() ? 
> heap.newOop(obj.getHandle().addOffsetToAsOopHandle(getOffset()), 
> (InlineKlass)getFieldKlass())
> 68:                     : heap.newOop(getValueAsOopHandle(obj));

This would be much more readable as an if/else block and if you assigned 
`obj.getHandle().addOffsetToAsOopHandle(getOffset())` to a Handle local 
variable.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32310#discussion_r3832187282
PR Review Comment: https://git.openjdk.org/jdk/pull/32310#discussion_r3832168590
PR Review Comment: https://git.openjdk.org/jdk/pull/32310#discussion_r3832139012

Reply via email to