On Thu, 10 Sep 2026 00:08:12 GMT, Chris Plummer <[email protected]> wrote:
>> 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. > > I'm pretty sure you are correct. So then the question is why doesn't this > cause any failures. I think the reason is because the only meaning override > done by Value is to make isValue() return true, and no one calls isValue(). > So then the question is why do we have Value? I think we don't actually need > it and FlattenValue can inherit from Instance instead, but I think it is a > cleaner abstraction to keep Value in place. So I suggest just reverse the > order of 185 and 186 and put a comment in explaining how the order matters. Thanks! Fixed, and added a comment. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/32310#discussion_r3974552345
