hotspot/src/share/vm/services/management.cpp
// Sets the memory pool sensor for a threshold type
JVM_ENTRY(void, jmm_SetPoolSensor(JNIEnv* env, jobject obj, jmmThresholdType type, jobject sensorObj))
{- -------------------------------------------
(1) もし MemoryPool オブジェクトであるべき引数 (以下の obj) や
Sensor オブジェクトであるべき引数 (以下の sensorObj) が
NULL だった場合は, NullPointerException.
---------------------------------------- -}
if (obj == NULL || sensorObj == NULL) {
THROW(vmSymbols::java_lang_NullPointerException());
}
{- -------------------------------------------
(1) もし, Sensor オブジェクトであるべき引数 (以下の sensorObj) が
Sensor クラスのインスタンスではなかったら, IllegalArgumentException.
---------------------------------------- -}
klassOop sensor_klass = Management::sun_management_Sensor_klass(CHECK);
oop s = JNIHandles::resolve(sensorObj);
assert(s->is_instance(), "Sensor should be an instanceOop");
instanceHandle sensor_h(THREAD, (instanceOop) s);
if (!sensor_h->is_a(sensor_klass)) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
"Sensor is not an instance of sun.management.Sensor class");
}
{- -------------------------------------------
(1) 引数で指定された MemoryPool に対して,
MemoryPool::set_usage_sensor_obj() または MemoryPool::set_gc_usage_sensor_obj() で
引数で渡された Sensor オブジェクトを登録する.
---------------------------------------- -}
MemoryPool* mpool = get_memory_pool_from_jobject(obj, CHECK);
assert(mpool != NULL, "MemoryPool should exist");
switch (type) {
case JMM_USAGE_THRESHOLD_HIGH:
case JMM_USAGE_THRESHOLD_LOW:
// have only one sensor for threshold high and low
mpool->set_usage_sensor_obj(sensor_h);
break;
case JMM_COLLECTION_USAGE_THRESHOLD_HIGH:
case JMM_COLLECTION_USAGE_THRESHOLD_LOW:
// have only one sensor for threshold high and low
mpool->set_gc_usage_sensor_obj(sensor_h);
break;
default:
assert(false, "Unrecognized type");
}
JVM_END
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.