Note that there are some explanatory texts on larger screens.

plurals
  1. POProgrammatic way to get address shown for Java monitors in a stack dump?
    primarykey
    data
    text
    <p>If you get the stack dump of a process, e.g., via jstack, you get information about locked monitors (and synchronizers) with an address for each. E.g., from a trivially deadlocked two-thread process (using jstack):</p> <pre><code>"Thread-0" prio=10 tid=0x00007f1444042000 nid=0x2818 waiting for monitor entry [0x00007f14433ca000] java.lang.Thread.State: BLOCKED (on object monitor) at scrap.DeadlockTest$Deadlocker.run(DeadlockTest.java:49) - waiting to lock &lt;0x00000007c14e6378&gt; (a java.lang.Object) - locked &lt;0x00000007c14e6368&gt; (a java.lang.Object) at java.lang.Thread.run(Thread.java:619) ... (omitted some lines here) Java stack information for the threads listed above: =================================================== "Thread-1": at scrap.DeadlockTest$Deadlocker.run(DeadlockTest.java:49) - waiting to lock &lt;0x00000007c14e6368&gt; (a java.lang.Object) - locked &lt;0x00000007c14e6378&gt; (a java.lang.Object) at java.lang.Thread.run(Thread.java:619) "Thread-0": at scrap.DeadlockTest$Deadlocker.run(DeadlockTest.java:49) - waiting to lock &lt;0x00000007c14e6378&gt; (a java.lang.Object) - locked &lt;0x00000007c14e6368&gt; (a java.lang.Object) at java.lang.Thread.run(Thread.java:619) </code></pre> <p>Is there any way to get, at runtime in the Java code, the same addresses shown above, such as <code>0x00000007c14e6368</code>?</p> <p>I've tried using the identity hash code on the objects the monitor correspond to, as well as <code>MonitorInfo</code> via <code>ThreadMXBean</code>, with no luck (the values don't correspond, at least on 64-bit java).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload