RFR: 8357650: ThreadSnapshot to take snapshot of thread for thread dumps
Chen Liang
liach at openjdk.org
Mon May 26 18:48:52 UTC 2025
On Sat, 24 May 2025 00:17:26 GMT, Alex Menkov <amenkov 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.
src/hotspot/share/classfile/javaClasses.cpp line 5519:
> 5517: oop java_util_concurrent_locks_AbstractOwnableSynchronizer::get_owner_threadObj(oop obj) {
> 5518: assert(_owner_offset != 0, "Must be initialized");
> 5519: return obj->obj_field_acquire(_owner_offset);
We might split this into a separate patch if this affects existing usages in threadService.cpp.
src/java.base/share/classes/jdk/internal/vm/ThreadSnapshot.java line 33:
> 31: * Represents a snapshot of information about a Thread.
> 32: */
> 33: class ThreadSnapshot {
All class declarations here should be made final (except enum and record which are already implicitly final)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25425#discussion_r2106198342
PR Review Comment: https://git.openjdk.org/jdk/pull/25425#discussion_r2106198093
PR Review Comment: https://git.openjdk.org/jdk/pull/25425#discussion_r2107742069
More information about the hotspot-dev
mailing list