// Implementation of "setflag" command static jint set_flag(AttachOperation* op, outputStream* out) { const char* name = NULL; if ((name = op->arg(0)) == NULL) { out->print_cr("flag name is missing"); return JNI_ERR; } Flag* f = Flag::find_flag((char*)name, strlen(name)); if (f && f->is_external() && f->is_writeable()) { if (f->is_bool()) { return set_bool_flag(name, op, out); } else if (f->is_intx()) { return set_intx_flag(name, op, out); } else if (f->is_uintx()) { return set_uintx_flag(name, op, out); } else if (f->is_uint64_t()) { return set_uint64_t_flag(name, op, out); } else if (f->is_ccstr()) { return set_ccstr_flag(name, op, out); } else { ShouldNotReachHere(); return JNI_ERR; } } else { return AttachListener::pd_set_flag(op, out); } }
// a writeable flag setter accepting 'jvalue' values int WriteableFlags::set_flag_from_jvalue(Flag* f, const void* value, Flag::Flags origin, FormatBuffer<80>& err_msg) { jvalue new_value = *(jvalue*)value; if (f->is_bool()) { bool bvalue = (new_value.z == JNI_TRUE ? true : false); return set_bool_flag(f->_name, bvalue, origin, err_msg); } else if (f->is_intx()) { intx ivalue = (intx)new_value.j; return set_intx_flag(f->_name, ivalue, origin, err_msg); } else if (f->is_uintx()) { uintx uvalue = (uintx)new_value.j; return set_uintx_flag(f->_name, uvalue, origin, err_msg); } else if (f->is_uint64_t()) { uint64_t uvalue = (uint64_t)new_value.j; return set_uint64_t_flag(f->_name, uvalue, origin, err_msg); } else if (f->is_size_t()) { size_t svalue = (size_t)new_value.j; return set_size_t_flag(f->_name, svalue, origin, err_msg); } else if (f->is_ccstr()) { oop str = JNIHandles::resolve_external_guard(new_value.l); if (str == NULL) { err_msg.print("flag value is missing"); return MISSING_VALUE; } ccstr svalue = java_lang_String::as_utf8_string(str); int ret = WriteableFlags::set_ccstr_flag(f->_name, svalue, origin, err_msg); if (ret != SUCCESS) { FREE_C_HEAP_ARRAY(char, svalue); } return ret; } else { ShouldNotReachHere(); } return ERR_OTHER; }
// set a uintx global flag int WriteableFlags::set_uintx_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) { uintx value; if (sscanf(arg, UINTX_FORMAT, &value)) { return set_uintx_flag(name, value, origin, err_msg); } err_msg.print("flag value must be an unsigned integer"); return WRONG_FORMAT; }
// a writeable flag setter accepting 'char *' values int WriteableFlags::set_flag_from_char(Flag* f, const void* value, Flag::Flags origin, FormatBuffer<80>& err_msg) { char* flag_value = *(char**)value; if (flag_value == NULL) { err_msg.print("flag value is missing"); return MISSING_VALUE; } if (f->is_bool()) { return set_bool_flag(f->_name, flag_value, origin, err_msg); } else if (f->is_intx()) { return set_intx_flag(f->_name, flag_value, origin, err_msg); } else if (f->is_uintx()) { return set_uintx_flag(f->_name, flag_value, origin, err_msg); } else if (f->is_uint64_t()) { return set_uint64_t_flag(f->_name, flag_value, origin, err_msg); } else if (f->is_size_t()) { return set_size_t_flag(f->_name, flag_value, origin, err_msg); } else if (f->is_ccstr()) { return set_ccstr_flag(f->_name, flag_value, origin, err_msg); } else { ShouldNotReachHere(); } return ERR_OTHER; }