RFR: 8357650: ThreadSnapshot to take snapshot of thread for thread dumps

Alex Menkov amenkov at openjdk.org
Tue May 27 19:02:04 UTC 2025


On Sun, 25 May 2025 13:12:23 GMT, Chen Liang <liach at openjdk.org> wrote:

>> This is first (hotspot) part of the update for `HotSpotDiagnosticMXBean.dumpThreads` and `jcmd Thread.dump_to_file` to include lock information in thread dumps (JDK-8356870).
>> The update has been split into parts to simplify reviewing.
>> The fix contains an implementation of `jdk.internal.vm.ThreadSnapshot` class to gather required information about a thread.
>> Second (dependent) part includes changes in `HotSpotDiagnosticMXBean.dumpThreads`/`jcmd Thread.dump_to_file`, spec updates and tests for the functionality.
>> 
>> Testing: new `HotSpotDiagnosticMXBean.dumpThreads`/`jcmd Thread.dump_to_file` functionality was tested in loom repo;
>>   sanity tier1 (this fix only)
>
> src/hotspot/share/classfile/javaClasses.cpp line 2241:
> 
>> 2239: }
>> 2240: 
>> 2241: class jdk_internal_vm_ThreadLock: AllStatic {
> 
> A bit unusual to declare class for java class in the cpp file - all others are declared in the hpp file.

`jdk_internal_vm_ThreadLock` and `jdk_internal_vm_ThreadSnapshot` classes are "local", they are used  only for `dump_to_file` diagnostic command, so I decide to not pollute javaClasses.hpp and initialize them on demand (most other classes are initialized on VM startup or read from cds)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25425#discussion_r2109950821


More information about the hotspot-dev mailing list