RFR: 8316417: ObjectMonitorIterator does not return the most recent monitor and is incorrect if no monitors exists

Axel Boldt-Christmas aboldtch at openjdk.org
Mon Sep 18 11:58:39 UTC 2023


On Mon, 18 Sep 2023 09:54:18 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:

> ObjectMonitorIterator fails to return the most resent monitor added. It start with returning the `nextOM()` ObjectMonitor from the `_head` ObjectMonitor but fails to ever return the `_head` ObjectMonitor.
> The current implementation can also not handle that the `_head` is nullptr (no monitors in the system) and returns a null ObjectMonitorIterator. Which is interpreted as `monitor list not supported, too old hotspot VM`.
> 
> Changed the iterator to keep return the current monitor (starts with `_head`) and decoupled `_head == nullptr` from the question if ObjectMonitorIterator is supported. 
> 
> Testing:
>   * Passes all `serviceability/sa` tests
>   * Currently running tier 1-3
>   * Currently running GHA

CDS tests are not happy with changing the class hierarchy of the LingeredApp. Unless it is easily solved for the CDS test I will revert those changes and have the 'TestObjectMonitorIterate' just do a less precise check of a lock on a Object. In the current JDK for LM_LEGACY and LM_LIGHTWEIGHT the `steadyStateObj` is the only object with a monitor when the SA agent queries.

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

PR Comment: https://git.openjdk.org/jdk/pull/15782#issuecomment-1723259794


More information about the serviceability-dev mailing list