On Thu, 22 Oct 2026 03:02:14 GMT, Yasumasa Suenaga <[email protected]> wrote:
>> src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/AbstractHeapGraphWriter.java
>> line 95:
>>
>>> 93: if
>>> (name.equals(javaLangThread)) {
>>> 94: writeThread(instance,
>>> flatObjects);
>>> 95: return false;
>>
>> I'm not sure why an early return is done here, but the consequence is that
>> the loop that drains flatObjects below is not executed, leaving references
>> to flattened Objects that are never written out. You might want to add a
>> test case for this if not too complicated.
>
> I moved dumper for `flatObjects` to `finally` block in new commit. I have no
> idea for testing because we cannot be sure `java.lang.Thread` could be a
> value object.
>
> BTW I'm not sure why this code work because this code seems to lack heap dump
> epilogue even though `writeHeapRecordPrologue()` is called at first. I
> confirmed ClhsdbDumpheap.java entered this block, but the test was passed
> normally...
writeHeapRecordEpilogue() doesn't do anything, so the missed call to it didn't
cause any problems.
This only impacts subclasses of Thread. For a test case you could try to define
a Thread subclass with a field that is a flattened value object.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/33395#discussion_r4344356824