hotspot/src/share/vm/prims/jvmtiExtensions.cpp
// return the list of extension functions
jvmtiError JvmtiExtensions::get_functions(JvmtiEnv* env,
jint* extension_count_ptr,
jvmtiExtensionFunctionInfo** extensions)
{
{- -------------------------------------------
(1) (assert)
---------------------------------------- -}
guarantee(_ext_functions != NULL, "registration not done");
{- -------------------------------------------
(1) (変数宣言など)
(See: ResourceTracker)
---------------------------------------- -}
ResourceTracker rt(env);
{- -------------------------------------------
(1)
---------------------------------------- -}
jvmtiExtensionFunctionInfo* ext_funcs;
jvmtiError err = rt.allocate(_ext_functions->length() *
sizeof(jvmtiExtensionFunctionInfo),
(unsigned char**)&ext_funcs);
if (err != JVMTI_ERROR_NONE) {
return err;
}
{- -------------------------------------------
(1)
---------------------------------------- -}
for (int i=0; i<_ext_functions->length(); i++ ) {
ext_funcs[i].func = _ext_functions->at(i)->func;
char *id = _ext_functions->at(i)->id;
err = rt.allocate(strlen(id)+1, (unsigned char**)&(ext_funcs[i].id));
if (err != JVMTI_ERROR_NONE) {
return err;
}
strcpy(ext_funcs[i].id, id);
char *desc = _ext_functions->at(i)->short_description;
err = rt.allocate(strlen(desc)+1,
(unsigned char**)&(ext_funcs[i].short_description));
if (err != JVMTI_ERROR_NONE) {
return err;
}
strcpy(ext_funcs[i].short_description, desc);
// params
jint param_count = _ext_functions->at(i)->param_count;
ext_funcs[i].param_count = param_count;
if (param_count == 0) {
ext_funcs[i].params = NULL;
} else {
err = rt.allocate(param_count*sizeof(jvmtiParamInfo),
(unsigned char**)&(ext_funcs[i].params));
if (err != JVMTI_ERROR_NONE) {
return err;
}
jvmtiParamInfo* src_params = _ext_functions->at(i)->params;
jvmtiParamInfo* dst_params = ext_funcs[i].params;
for (int j=0; j<param_count; j++) {
err = rt.allocate(strlen(src_params[j].name)+1,
(unsigned char**)&(dst_params[j].name));
if (err != JVMTI_ERROR_NONE) {
return err;
}
strcpy(dst_params[j].name, src_params[j].name);
dst_params[j].kind = src_params[j].kind;
dst_params[j].base_type = src_params[j].base_type;
dst_params[j].null_ok = src_params[j].null_ok;
}
}
// errors
jint error_count = _ext_functions->at(i)->error_count;
ext_funcs[i].error_count = error_count;
if (error_count == 0) {
ext_funcs[i].errors = NULL;
} else {
err = rt.allocate(error_count*sizeof(jvmtiError),
(unsigned char**)&(ext_funcs[i].errors));
if (err != JVMTI_ERROR_NONE) {
return err;
}
memcpy(ext_funcs[i].errors, _ext_functions->at(i)->errors,
error_count*sizeof(jvmtiError));
}
}
{- -------------------------------------------
(1)
---------------------------------------- -}
*extension_count_ptr = _ext_functions->length();
*extensions = ext_funcs;
return JVMTI_ERROR_NONE;
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.