RFR: 8368527: JMX: Add an MXBeans method to query GC CPU time [v2]
Jonas Norlinder
duke at openjdk.org
Mon Oct 6 12:22:48 UTC 2025
On Mon, 6 Oct 2025 11:46:06 GMT, Alan Bateman <alanb at openjdk.org> wrote:
> I'm also wondering about ThreadMXBean::isThreadCpuTimeSupported. Is it possible for this to return false but getTotalGcCpuTime to return a value >= 0.
`ThreadMXBean::isThreadCpuTimeSupported` uses the value from `os::is_thread_cpu_time_supported`:
https://github.com/openjdk/jdk/blob/6431310109a02ec5c34f877a1c690afb00193043/src/hotspot/share/services/management.cpp#L131-L137
I ensure to always return `-1` if thread cpu time is not supported as this is the contract that is promised by the documentation.
https://github.com/openjdk/jdk/blob/6431310109a02ec5c34f877a1c690afb00193043/src/hotspot/share/services/management.cpp#L894-L896
So, no this is not possible. However, `is_thread_cpu_time_enabled` is not being considered, but as you say, this method only concerns Java threads.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27537#discussion_r2405993712
More information about the hotspot-dev
mailing list