JDK-8325314 : Release Note: The Implementation of JVMTI `GetObjectMonitorUsage` Has Been Corrected
  • Type: Sub-task
  • Component: hotspot
  • Sub-Component: jvmti
  • Affected Version: 23
  • Priority: P4
  • Status: Resolved
  • Resolution: Delivered
  • Submitted: 2024-02-06
  • Updated: 2024-03-15
  • Resolved: 2024-03-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 23
23Resolved
Related Reports
Relates :  
Description
The JVMTI `GetObjectMonitorUsage` function returns the following data structure:
```
    typedef struct {
        jthread owner;
        jint entry_count;
        jint waiter_count;
        jthread* waiters;
        jint notify_waiter_count;
        jthread* notify_waiters;
    } jvmtiMonitorUsage;
```

Two fields in this structure are specified as:
- `waiter_count` [`jint`]: The number of threads waiting to own this monitor
- `waiters` [`jthread*`]: The `waiter_count` waiting threads

In previous releases, the `waiters` field included the threads waiting to enter or re-enter the monitor as specified, but also (incorrectly) the threads waiting to be notified in `java.lang.Object.wait()`. That has been fixed in the current release. The `waiter_count` always matches the returned number of threads in the `waiters` field.

Also, the JDWP `ObjectReference.MonitorInfo` command spec was updated to clarify what the `waiters` threads are:
>   `waiters`: "The total number of threads that are waiting to enter or re-enter the monitor, or waiting to be notified by the monitor."

The behavior of this JDWP command is kept the same, and is intentionally different to `GetObjectMonitorUsage`.
Comments
Note the suggested title does not say "spec" anywhere. The intent, as per Chris's original suggestion is just to use "keywords" so that it is drawn to the attention of anyone interested in JVM TI or JDWP. They can then read the details in the actual RN.
06-03-2024

Thank you, David. Your last suggestion is not fully correct. In fact, the JVMTI impl was corrected to match the spec and the JDWP spec.
05-03-2024

As per GetContendedMonitorInfo the title here may be better expressed as: The Meaning of "waiting threads" has Been Clarified in JVM TI and JDWP
05-03-2024

I've reformatted in markdown and taken an editorial pass over this.
04-03-2024