On Wed, 12 Aug 2026 07:51:49 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:
>
> Improve OopField::getOffset
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Inline.java line 47:
> 45: // TODO
> 46: //Type type = db.lookupType("inlineOopDesc");
> 47: }
Why is this not implemented?
EDIT: I think this stems from my comment below on how this class is not
actually a mirror for inlineOop.
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Inline.java line 61:
> 59: public boolean isInline() {
> 60: return true;
> 61: }
I don't think this is used.
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/Inline.java line 64:
> 62:
> 63: public boolean isFlattened() {
> 64: return klass != null;
It's confusing how the setting of `klass` is the flag that determines if this
represents an oop for a flattened field (I assume this will eventually extend
to locals and array elements), or is just for a regular heap object.
There is also the issue of class being inlineable vs actually being inlined.
This class at first seems to mirror inlineOop, but in fact it does not since
inlineOop only references actual heap objects. So this class is instead is an
SA specific way of having and "oop" reference a flattened field. I think this
needs to be made more clear.
Perhaps this class shouldn't be used if the inlineable type is not flattened.
newOop(OopHandle) can just create an `Instance` when the Klass is InlineKlass
intead of an `Inline` with no klass. It doesn't seem that there is any place in
SA where it needs to know if the Instance is an InlineKlass or just
InstanceKlass. newOop(OopHandle, InlineKlass) can be used only when the field
is flattened. If you go this route, you might want to rename this klass to
FlattenedInstance.
I'm ok if you want to keep it as-is, but the purpose of this class needs to
better explained and probably given a different name to avoid the incorrect
Inline == inlineOop assumption.
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InlineKlass.java line
37:
> 35: import sun.jvm.hotspot.utilities.Observer;
> 36:
> 37: // An InlineKlass is the VM level representation of a flattable Java
> class.
Suggestion:
// An InlineKlass is the VM level representation of a flattenable Java class.
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
line 893:
> 891: }
> 892:
> 893: public Address getAdrInlineKlassMembers() {
Suggestion:
public Address getAddressOfInlineKlassMembers() {
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
line 894:
> 892:
> 893: public Address getAdrInlineKlassMembers() {
> 894: return getAddress().getAddressAt(adrInlineKlassMembers.getOffset());
Suggestion:
return getAddress().getAddressAt(addressOfInlineKlassMembers.getOffset());
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/OopField.java line 35:
> 33: public class OopField extends Field {
> 34:
> 35: private final InlineKlass inlineKlass;
So this is set to the InlineKlass only if this Field references an InlineKlass
and it has been flattened? If so, please add a comment.
src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/OopField.java line 64:
> 62: public long getOffset() {
> 63: long ofs = super.getOffset();
> 64: if ((inlineKlass != null) || (inlineKlass == null && isFlat())) {
Can you explain a bit how this works. I thought an InstanceKlass that is
inlineable is marked as such, but that doesn't imply it will actually be
inlined (flattened) for every field reference. The field referencing the
inlineable class is marked as "flat" if it is actually flattened. How do we end
up with (inlineKlass == null && isFlat()) being true? I would think that
isFlat() being true would imply (inlineKlass != null) being true.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/32310#discussion_r3769844081
PR Review Comment: https://git.openjdk.org/jdk/pull/32310#discussion_r3770727974
PR Review Comment: https://git.openjdk.org/jdk/pull/32310#discussion_r3770765331
PR Review Comment: https://git.openjdk.org/jdk/pull/32310#discussion_r3769923751
PR Review Comment: https://git.openjdk.org/jdk/pull/32310#discussion_r3769936255
PR Review Comment: https://git.openjdk.org/jdk/pull/32310#discussion_r3770785734
PR Review Comment: https://git.openjdk.org/jdk/pull/32310#discussion_r3770597294
PR Review Comment: https://git.openjdk.org/jdk/pull/32310#discussion_r3770634321