< prev index next >

src/hotspot/share/prims/jvmtiEnvBase.cpp

Print this page
*** 986,11 ***
      }
    }
  
    // Get off stack monitors. (e.g. acquired via jni MonitorEnter).
    JvmtiMonitorClosure jmc(calling_thread, owned_monitors_list, this);
!   ObjectSynchronizer::monitors_iterate(&jmc, java_thread);
    err = jmc.error();
  
    return err;
  }
  
--- 986,11 ---
      }
    }
  
    // Get off stack monitors. (e.g. acquired via jni MonitorEnter).
    JvmtiMonitorClosure jmc(calling_thread, owned_monitors_list, this);
!   ObjectSynchronizer::owned_monitors_iterate(&jmc, java_thread);
    err = jmc.error();
  
    return err;
  }
  

*** 1013,11 ***
      }
    }
  
    // Get off stack monitors. (e.g. acquired via jni MonitorEnter).
    JvmtiMonitorClosure jmc(calling_thread, owned_monitors_list, this);
!   ObjectSynchronizer::monitors_iterate(&jmc, java_thread);
    err = jmc.error();
  
    return err;
  }
  
--- 1013,11 ---
      }
    }
  
    // Get off stack monitors. (e.g. acquired via jni MonitorEnter).
    JvmtiMonitorClosure jmc(calling_thread, owned_monitors_list, this);
!   ObjectSynchronizer::owned_monitors_iterate(&jmc, java_thread);
    err = jmc.error();
  
    return err;
  }
  

*** 2176,10 ***
--- 2176,17 ---
      // to the list.
      return;
    }
    // Filter out on stack monitors collected during stack walk.
    oop obj = mon->object();
+ 
+   if (obj == nullptr) {
+     // This can happen if JNI code drops all references to the
+     // owning object.
+     return;
+   }
+ 
    bool found = false;
    for (int j = 0; j < _owned_monitors_list->length(); j++) {
      jobject jobj = ((jvmtiMonitorStackDepthInfo*)_owned_monitors_list->at(j))->monitor;
      oop check = JNIHandles::resolve(jobj);
      if (check == obj) {
< prev index next >