What are the "waiting on <no object reference available>" entries in Java Virtual Machine (JVM) Thread dumps ?

What are the "waiting on <no object reference available>" entries in Java Virtual Machine (JVM) Thread dumps ?

book

Article ID: KB0071297

calendar_today

Updated On:

Products Versions
TIBCO Data Virtualization -

Description

We typically observe entries in the thread dump that look something like this : 

java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(java.base@11.0.12/Native Method)
- waiting on <no object reference available>
at java.lang.Object.wait(java.base@11.0.12/Object.java:328)
at com.compositesw.server.cache.CacheTaskThread.waitForAutoCreate(CacheTaskThread.java:211)

 

Issue/Introduction

Reason of why JVM Thread dump show "Waiting on " in the logs.

Resolution

This is a peculiarity of JVM. When dumping a stack, JVM recovers the wait object from the method local variables.
This info is available for interpreted methods, but not for compiled native wrappers.
When Object.wait is executed frequently enough, it gets JIT-compiled. After that there will be no "waiting on" line in a thread dump.
Since wait() must be called on a synchronized object, most often the wait object is the last locked object in the stack trace.

This do not affect the thread dump generation in any way or is not indicative of an error condition with generating thread dumps and can safely be ignored. 

Additional Information

https://stackoverflow.com/questions/25701740/java-thread-dump-waiting-on-object-monitor-what-is-it-waiting-on