< prev index next >

src/hotspot/share/prims/jvmtiEnvBase.cpp

Print this page
@@ -54,10 +54,11 @@
  #include "runtime/jniHandles.inline.hpp"
  #include "runtime/objectMonitor.inline.hpp"
  #include "runtime/osThread.hpp"
  #include "runtime/signature.hpp"
  #include "runtime/stackWatermarkSet.inline.hpp"
+ #include "runtime/synchronizer.inline.hpp"
  #include "runtime/threads.hpp"
  #include "runtime/threadSMR.inline.hpp"
  #include "runtime/vframe.inline.hpp"
  #include "runtime/vframe_hp.hpp"
  #include "runtime/vmThread.hpp"

@@ -1463,11 +1464,10 @@
      hobj = Handle(current_thread, mirror);
    }
  
    ThreadsListHandle tlh(current_thread);
    JavaThread *owning_thread = nullptr;
-   ObjectMonitor *mon = nullptr;
    jvmtiMonitorUsage ret = {
        nullptr, 0, 0, nullptr, 0, nullptr
    };
  
    uint32_t debug_bits = 0;

@@ -1493,12 +1493,15 @@
    jint nWant = 0, nWait = 0;
    markWord mark = hobj->mark();
    ResourceMark rm(current_thread);
    GrowableArray<JavaThread*>* wantList = nullptr;
  
-   if (mark.has_monitor()) {
-     mon = mark.monitor();
+   ObjectMonitor* mon = mark.has_monitor()
+       ? ObjectSynchronizer::read_monitor(current_thread, hobj(), mark)
+       : nullptr;
+ 
+   if (mon != nullptr) {
      assert(mon != nullptr, "must have monitor");
      // this object has a heavyweight monitor
      nWant = mon->contentions(); // # of threads contending for monitor entry, but not re-entry
      nWait = mon->waiters();     // # of threads waiting for notification,
                                  // or to re-enter monitor, in Object.wait()
< prev index next >