src/share/vm/prims/jvmtiEnvBase.cpp

Print this page




1458         break;
1459       }
1460     }
1461     if (found == false) {
1462       // This is off stack monitor (e.g. acquired via jni MonitorEnter).
1463       jvmtiError err;
1464       jvmtiMonitorStackDepthInfo *jmsdi;
1465       err = _env->allocate(sizeof(jvmtiMonitorStackDepthInfo), (unsigned char **)&jmsdi);
1466       if (err != JVMTI_ERROR_NONE) {
1467         _error = err;
1468         return;
1469       }
1470       Handle hobj(obj);
1471       jmsdi->monitor = _env->jni_reference(_calling_thread, hobj);
1472       // stack depth is unknown for this monitor.
1473       jmsdi->stack_depth = -1;
1474       _owned_monitors_list->append(jmsdi);
1475     }
1476   }
1477 }


































1458         break;
1459       }
1460     }
1461     if (found == false) {
1462       // This is off stack monitor (e.g. acquired via jni MonitorEnter).
1463       jvmtiError err;
1464       jvmtiMonitorStackDepthInfo *jmsdi;
1465       err = _env->allocate(sizeof(jvmtiMonitorStackDepthInfo), (unsigned char **)&jmsdi);
1466       if (err != JVMTI_ERROR_NONE) {
1467         _error = err;
1468         return;
1469       }
1470       Handle hobj(obj);
1471       jmsdi->monitor = _env->jni_reference(_calling_thread, hobj);
1472       // stack depth is unknown for this monitor.
1473       jmsdi->stack_depth = -1;
1474       _owned_monitors_list->append(jmsdi);
1475     }
1476   }
1477 }
1478 
1479 GrowableArray<jobject>* JvmtiModuleClosure::_tbl = NULL;
1480 
1481 jvmtiError
1482 JvmtiModuleClosure::get_all_modules(JvmtiEnv* env, jint* module_count_ptr, jobject** modules_ptr) {
1483   ResourceMark rm;
1484   MutexLocker ml(Module_lock);
1485 
1486   _tbl = new GrowableArray<jobject>(40, true);
1487   if (_tbl == NULL) {
1488     return JVMTI_ERROR_OUT_OF_MEMORY;
1489   }
1490 
1491   // Iterate over all the modules loaded to the system.
1492   ClassLoaderDataGraph::modules_do(&do_module);
1493 
1494   jint len = _tbl->length();
1495   guarantee(len > 0, "at least one module must be present");
1496 
1497   jobject* array = (jobject*)env->jvmtiMalloc((jlong)(len * sizeof(jobject)));
1498   if (array == NULL) {
1499     return JVMTI_ERROR_OUT_OF_MEMORY;
1500   }
1501   for (jint idx = 0; idx < len; idx++) {
1502     array[idx] = _tbl->at(idx);
1503   }
1504   _tbl = NULL;
1505   *modules_ptr = array;
1506   *module_count_ptr = len;
1507   return JVMTI_ERROR_NONE;
1508 }
1509