8224878: Use JVMFlag parameters instead of name strings
authorstefank
Mon, 26 Aug 2019 09:15:43 +0200
changeset 57876 30db6422848b
parent 57875 427b38332f20
child 57877 eebdf6aa4907
8224878: Use JVMFlag parameters instead of name strings Reviewed-by: gziemski, dholmes, jrose
src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp
src/hotspot/share/prims/whitebox.cpp
src/hotspot/share/runtime/arguments.cpp
src/hotspot/share/runtime/flags/jvmFlag.cpp
src/hotspot/share/runtime/flags/jvmFlag.hpp
src/hotspot/share/runtime/flags/jvmFlagConstraintList.cpp
src/hotspot/share/runtime/flags/jvmFlagConstraintList.hpp
src/hotspot/share/runtime/flags/jvmFlagRangeList.cpp
src/hotspot/share/runtime/flags/jvmFlagRangeList.hpp
src/hotspot/share/runtime/globals_extension.hpp
src/hotspot/share/services/attachListener.cpp
src/hotspot/share/services/dtraceAttacher.cpp
src/hotspot/share/services/management.cpp
src/hotspot/share/services/writeableFlags.cpp
--- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp	Mon Aug 26 09:13:38 2019 +0200
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp	Mon Aug 26 09:15:43 2019 +0200
@@ -205,7 +205,7 @@
     JVMCI_THROW_NULL(NullPointerException);
   }
   const char* cstring = JVMCIENV->as_utf8_string(name);
-  JVMFlag* flag = JVMFlag::find_flag(cstring, strlen(cstring), /* allow_locked */ true, /* return_flag */ true);
+  const JVMFlag* flag = JVMFlag::find_declared_flag(cstring);
   if (flag == NULL) {
     return c2vm;
   }
--- a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp	Mon Aug 26 09:13:38 2019 +0200
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp	Mon Aug 26 09:15:43 2019 +0200
@@ -369,7 +369,7 @@
 #define COUNT_FLAG(ignore) +1
 #ifdef ASSERT
 #define CHECK_FLAG(type, name) { \
-  JVMFlag* flag = JVMFlag::find_flag(#name, strlen(#name), /*allow_locked*/ true, /* return_flag */ true); \
+  const JVMFlag* flag = JVMFlag::find_declared_flag(#name); \
   assert(flag != NULL, "No such flag named " #name); \
   assert(flag->is_##type(), "JVMFlag " #name " is not of type " #type); \
 }
--- a/src/hotspot/share/prims/whitebox.cpp	Mon Aug 26 09:13:38 2019 +0200
+++ b/src/hotspot/share/prims/whitebox.cpp	Mon Aug 26 09:15:43 2019 +0200
@@ -1137,27 +1137,29 @@
 WB_END
 
 template <typename T>
-static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, JVMFlag::Error (*TAt)(const char*, T*, bool, bool)) {
+static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, JVMFlag::Error (*TAt)(const JVMFlag*, T*)) {
   if (name == NULL) {
     return false;
   }
   ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
   const char* flag_name = env->GetStringUTFChars(name, NULL);
   CHECK_JNI_EXCEPTION_(env, false);
-  JVMFlag::Error result = (*TAt)(flag_name, value, true, true);
+  const JVMFlag* flag = JVMFlag::find_declared_flag(flag_name);
+  JVMFlag::Error result = (*TAt)(flag, value);
   env->ReleaseStringUTFChars(name, flag_name);
   return (result == JVMFlag::SUCCESS);
 }
 
 template <typename T>
-static bool SetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, JVMFlag::Error (*TAtPut)(const char*, T*, JVMFlag::Flags)) {
+static bool SetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, JVMFlag::Error (*TAtPut)(JVMFlag* flag, T*, JVMFlag::Flags)) {
   if (name == NULL) {
     return false;
   }
   ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
   const char* flag_name = env->GetStringUTFChars(name, NULL);
   CHECK_JNI_EXCEPTION_(env, false);
-  JVMFlag::Error result = (*TAtPut)(flag_name, value, JVMFlag::INTERNAL);
+  JVMFlag* flag = JVMFlag::find_flag(flag_name);
+  JVMFlag::Error result = (*TAtPut)(flag, value, JVMFlag::INTERNAL);
   env->ReleaseStringUTFChars(name, flag_name);
   return (result == JVMFlag::SUCCESS);
 }
@@ -1192,22 +1194,22 @@
   return box(thread, env, vmSymbols::java_lang_Double(), vmSymbols::Double_valueOf_signature(), value);
 }
 
-static JVMFlag* getVMFlag(JavaThread* thread, JNIEnv* env, jstring name) {
+static const JVMFlag* getVMFlag(JavaThread* thread, JNIEnv* env, jstring name) {
   ThreadToNativeFromVM ttnfv(thread);   // can't be in VM when we call JNI
   const char* flag_name = env->GetStringUTFChars(name, NULL);
   CHECK_JNI_EXCEPTION_(env, NULL);
-  JVMFlag* result = JVMFlag::find_flag(flag_name, strlen(flag_name), true, true);
+  const JVMFlag* result = JVMFlag::find_declared_flag(flag_name);
   env->ReleaseStringUTFChars(name, flag_name);
   return result;
 }
 
 WB_ENTRY(jboolean, WB_IsConstantVMFlag(JNIEnv* env, jobject o, jstring name))
-  JVMFlag* flag = getVMFlag(thread, env, name);
+  const JVMFlag* flag = getVMFlag(thread, env, name);
   return (flag != NULL) && flag->is_constant_in_binary();
 WB_END
 
 WB_ENTRY(jboolean, WB_IsLockedVMFlag(JNIEnv* env, jobject o, jstring name))
-  JVMFlag* flag = getVMFlag(thread, env, name);
+  const JVMFlag* flag = getVMFlag(thread, env, name);
   return (flag != NULL) && !(flag->is_unlocked() || flag->is_unlocker());
 WB_END
 
--- a/src/hotspot/share/runtime/arguments.cpp	Mon Aug 26 09:13:38 2019 +0200
+++ b/src/hotspot/share/runtime/arguments.cpp	Mon Aug 26 09:15:43 2019 +0200
@@ -750,7 +750,7 @@
 
       // if flag has become obsolete it should not have a "globals" flag defined anymore.
       if (!version_less_than(JDK_Version::current(), flag.obsolete_in)) {
-        if (JVMFlag::find_flag(flag.name) != NULL) {
+        if (JVMFlag::find_declared_flag(flag.name) != NULL) {
           // Temporarily disable the warning: 8196739
           // warning("Global variable for obsolete special flag entry \"%s\" should be removed", flag.name);
         }
@@ -760,7 +760,7 @@
     if (!flag.expired_in.is_undefined()) {
       // if flag has become expired it should not have a "globals" flag defined anymore.
       if (!version_less_than(JDK_Version::current(), flag.expired_in)) {
-        if (JVMFlag::find_flag(flag.name) != NULL) {
+        if (JVMFlag::find_declared_flag(flag.name) != NULL) {
           // Temporarily disable the warning: 8196739
           // warning("Global variable for expired flag entry \"%s\" should be removed", flag.name);
         }
@@ -844,15 +844,15 @@
   }
 }
 
-static bool set_bool_flag(const char* name, bool value, JVMFlag::Flags origin) {
-  if (JVMFlag::boolAtPut(name, &value, origin) == JVMFlag::SUCCESS) {
+static bool set_bool_flag(JVMFlag* flag, bool value, JVMFlag::Flags origin) {
+  if (JVMFlag::boolAtPut(flag, &value, origin) == JVMFlag::SUCCESS) {
     return true;
   } else {
     return false;
   }
 }
 
-static bool set_fp_numeric_flag(const char* name, char* value, JVMFlag::Flags origin) {
+static bool set_fp_numeric_flag(JVMFlag* flag, char* value, JVMFlag::Flags origin) {
   char* end;
   errno = 0;
   double v = strtod(value, &end);
@@ -860,26 +860,25 @@
     return false;
   }
 
-  if (JVMFlag::doubleAtPut(name, &v, origin) == JVMFlag::SUCCESS) {
+  if (JVMFlag::doubleAtPut(flag, &v, origin) == JVMFlag::SUCCESS) {
     return true;
   }
   return false;
 }
 
-static bool set_numeric_flag(const char* name, char* value, JVMFlag::Flags origin) {
+static bool set_numeric_flag(JVMFlag* flag, char* value, JVMFlag::Flags origin) {
   julong v;
   int int_v;
   intx intx_v;
   bool is_neg = false;
-  JVMFlag* result = JVMFlag::find_flag(name, strlen(name));
-
-  if (result == NULL) {
+
+  if (flag == NULL) {
     return false;
   }
 
   // Check the sign first since atojulong() parses only unsigned values.
   if (*value == '-') {
-    if (!result->is_intx() && !result->is_int()) {
+    if (!flag->is_intx() && !flag->is_int()) {
       return false;
     }
     value++;
@@ -888,48 +887,48 @@
   if (!Arguments::atojulong(value, &v)) {
     return false;
   }
-  if (result->is_int()) {
+  if (flag->is_int()) {
     int_v = (int) v;
     if (is_neg) {
       int_v = -int_v;
     }
-    return JVMFlag::intAtPut(result, &int_v, origin) == JVMFlag::SUCCESS;
-  } else if (result->is_uint()) {
+    return JVMFlag::intAtPut(flag, &int_v, origin) == JVMFlag::SUCCESS;
+  } else if (flag->is_uint()) {
     uint uint_v = (uint) v;
-    return JVMFlag::uintAtPut(result, &uint_v, origin) == JVMFlag::SUCCESS;
-  } else if (result->is_intx()) {
+    return JVMFlag::uintAtPut(flag, &uint_v, origin) == JVMFlag::SUCCESS;
+  } else if (flag->is_intx()) {
     intx_v = (intx) v;
     if (is_neg) {
       intx_v = -intx_v;
     }
-    return JVMFlag::intxAtPut(result, &intx_v, origin) == JVMFlag::SUCCESS;
-  } else if (result->is_uintx()) {
+    return JVMFlag::intxAtPut(flag, &intx_v, origin) == JVMFlag::SUCCESS;
+  } else if (flag->is_uintx()) {
     uintx uintx_v = (uintx) v;
-    return JVMFlag::uintxAtPut(result, &uintx_v, origin) == JVMFlag::SUCCESS;
-  } else if (result->is_uint64_t()) {
+    return JVMFlag::uintxAtPut(flag, &uintx_v, origin) == JVMFlag::SUCCESS;
+  } else if (flag->is_uint64_t()) {
     uint64_t uint64_t_v = (uint64_t) v;
-    return JVMFlag::uint64_tAtPut(result, &uint64_t_v, origin) == JVMFlag::SUCCESS;
-  } else if (result->is_size_t()) {
+    return JVMFlag::uint64_tAtPut(flag, &uint64_t_v, origin) == JVMFlag::SUCCESS;
+  } else if (flag->is_size_t()) {
     size_t size_t_v = (size_t) v;
-    return JVMFlag::size_tAtPut(result, &size_t_v, origin) == JVMFlag::SUCCESS;
-  } else if (result->is_double()) {
+    return JVMFlag::size_tAtPut(flag, &size_t_v, origin) == JVMFlag::SUCCESS;
+  } else if (flag->is_double()) {
     double double_v = (double) v;
-    return JVMFlag::doubleAtPut(result, &double_v, origin) == JVMFlag::SUCCESS;
+    return JVMFlag::doubleAtPut(flag, &double_v, origin) == JVMFlag::SUCCESS;
   } else {
     return false;
   }
 }
 
-static bool set_string_flag(const char* name, const char* value, JVMFlag::Flags origin) {
-  if (JVMFlag::ccstrAtPut(name, &value, origin) != JVMFlag::SUCCESS) return false;
+static bool set_string_flag(JVMFlag* flag, const char* value, JVMFlag::Flags origin) {
+  if (JVMFlag::ccstrAtPut(flag, &value, origin) != JVMFlag::SUCCESS) return false;
   // Contract:  JVMFlag always returns a pointer that needs freeing.
   FREE_C_HEAP_ARRAY(char, value);
   return true;
 }
 
-static bool append_to_string_flag(const char* name, const char* new_value, JVMFlag::Flags origin) {
+static bool append_to_string_flag(JVMFlag* flag, const char* new_value, JVMFlag::Flags origin) {
   const char* old_value = "";
-  if (JVMFlag::ccstrAt(name, &old_value) != JVMFlag::SUCCESS) return false;
+  if (JVMFlag::ccstrAt(flag, &old_value) != JVMFlag::SUCCESS) return false;
   size_t old_len = old_value != NULL ? strlen(old_value) : 0;
   size_t new_len = strlen(new_value);
   const char* value;
@@ -946,7 +945,7 @@
     value = buf;
     free_this_too = buf;
   }
-  (void) JVMFlag::ccstrAtPut(name, &value, origin);
+  (void) JVMFlag::ccstrAtPut(flag, &value, origin);
   // JVMFlag always returns a pointer that needs freeing.
   FREE_C_HEAP_ARRAY(char, value);
   if (free_this_too != NULL) {
@@ -1041,7 +1040,8 @@
     if (real_name == NULL) {
       return false;
     }
-    return set_bool_flag(real_name, false, origin);
+    JVMFlag* flag = JVMFlag::find_flag(real_name);
+    return set_bool_flag(flag, false, origin);
   }
   if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
     AliasedLoggingFlag alf = catch_logging_aliases(name, true);
@@ -1053,13 +1053,13 @@
     if (real_name == NULL) {
       return false;
     }
-    return set_bool_flag(real_name, true, origin);
+    JVMFlag* flag = JVMFlag::find_flag(real_name);
+    return set_bool_flag(flag, true, origin);
   }
 
   char punct;
   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') {
     const char* value = strchr(arg, '=') + 1;
-    JVMFlag* flag;
 
     // this scanf pattern matches both strings (handled here) and numbers (handled later))
     AliasedLoggingFlag alf = catch_logging_aliases(name, true);
@@ -1071,15 +1071,15 @@
     if (real_name == NULL) {
       return false;
     }
-    flag = JVMFlag::find_flag(real_name);
+    JVMFlag* flag = JVMFlag::find_flag(real_name);
     if (flag != NULL && flag->is_ccstr()) {
       if (flag->ccstr_accumulates()) {
-        return append_to_string_flag(real_name, value, origin);
+        return append_to_string_flag(flag, value, origin);
       } else {
         if (value[0] == '\0') {
           value = NULL;
         }
-        return set_string_flag(real_name, value, origin);
+        return set_string_flag(flag, value, origin);
       }
     } else {
       warn_if_deprecated = false; // if arg is deprecated, we've already done warning...
@@ -1096,7 +1096,8 @@
     if (real_name == NULL) {
       return false;
     }
-    return set_string_flag(real_name, value, origin);
+    JVMFlag* flag = JVMFlag::find_flag(real_name);
+    return set_string_flag(flag, value, origin);
   }
 
 #define SIGNED_FP_NUMBER_RANGE "[-0123456789.eE+]"
@@ -1111,7 +1112,8 @@
       if (real_name == NULL) {
         return false;
       }
-      return set_fp_numeric_flag(real_name, value, origin);
+      JVMFlag* flag = JVMFlag::find_flag(real_name);
+      return set_fp_numeric_flag(flag, value, origin);
     }
   }
 
@@ -1121,7 +1123,8 @@
     if (real_name == NULL) {
       return false;
     }
-    return set_numeric_flag(real_name, value, origin);
+    JVMFlag* flag = JVMFlag::find_flag(real_name);
+    return set_numeric_flag(flag, value, origin);
   }
 
   return false;
@@ -1277,7 +1280,7 @@
 
   // For locked flags, report a custom error message if available.
   // Otherwise, report the standard unrecognized VM option.
-  JVMFlag* found_flag = JVMFlag::find_flag((const char*)argname, arg_len, true, true);
+  const JVMFlag* found_flag = JVMFlag::find_declared_flag((const char*)argname, arg_len);
   if (found_flag != NULL) {
     char locked_message_buf[BUFLEN];
     JVMFlag::MsgType msg_type = found_flag->get_locked_message(locked_message_buf, BUFLEN);
--- a/src/hotspot/share/runtime/flags/jvmFlag.cpp	Mon Aug 26 09:13:38 2019 +0200
+++ b/src/hotspot/share/runtime/flags/jvmFlag.cpp	Mon Aug 26 09:15:43 2019 +0200
@@ -604,7 +604,7 @@
       st->cr();
       return;
     }
-    JVMFlagRangeList::print(st, _name, func);
+    JVMFlagRangeList::print(st, this, func);
 
     fill_to_pos(st, col5_pos);
     print_kind(st, col5_width);
@@ -957,103 +957,82 @@
 }
 
 // Returns the address of the index'th element
-static JVMFlag* address_of_flag(JVMFlagsEnum flag) {
+JVMFlag* JVMFlagEx::flag_from_enum(JVMFlagsEnum flag) {
   assert((size_t)flag < JVMFlag::numFlags, "bad command line flag index");
   return &JVMFlag::flags[flag];
 }
 
 bool JVMFlagEx::is_default(JVMFlagsEnum flag) {
-  assert((size_t)flag < JVMFlag::numFlags, "bad command line flag index");
-  JVMFlag* f = &JVMFlag::flags[flag];
-  return f->is_default();
+  return flag_from_enum(flag)->is_default();
 }
 
 bool JVMFlagEx::is_ergo(JVMFlagsEnum flag) {
-  assert((size_t)flag < JVMFlag::numFlags, "bad command line flag index");
-  JVMFlag* f = &JVMFlag::flags[flag];
-  return f->is_ergonomic();
+  return flag_from_enum(flag)->is_ergonomic();
 }
 
 bool JVMFlagEx::is_cmdline(JVMFlagsEnum flag) {
-  assert((size_t)flag < JVMFlag::numFlags, "bad command line flag index");
-  JVMFlag* f = &JVMFlag::flags[flag];
-  return f->is_command_line();
-}
-
-bool JVMFlag::wasSetOnCmdline(const char* name, bool* value) {
-  JVMFlag* result = JVMFlag::find_flag((char*)name, strlen(name));
-  if (result == NULL) return false;
-  *value = result->is_command_line();
-  return true;
+  return flag_from_enum(flag)->is_command_line();
 }
 
 void JVMFlagEx::setOnCmdLine(JVMFlagsEnum flag) {
-  JVMFlag* faddr = address_of_flag(flag);
+  JVMFlag* faddr = flag_from_enum(flag);
   assert(faddr != NULL, "Unknown flag");
   faddr->set_command_line();
 }
 
 template<class E, class T>
-static void trace_flag_changed(const char* name, const T old_value, const T new_value, const JVMFlag::Flags origin) {
+static void trace_flag_changed(const JVMFlag* flag, const T old_value, const T new_value, const JVMFlag::Flags origin) {
   E e;
-  e.set_name(name);
+  e.set_name(flag->_name);
   e.set_oldValue(old_value);
   e.set_newValue(new_value);
   e.set_origin(origin);
   e.commit();
 }
 
-static JVMFlag::Error apply_constraint_and_check_range_bool(const char* name, bool new_value, bool verbose) {
+static JVMFlag::Error apply_constraint_and_check_range_bool(const JVMFlag* flag, bool new_value, bool verbose) {
   JVMFlag::Error status = JVMFlag::SUCCESS;
-  JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(name);
+  JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
   if (constraint != NULL) {
     status = constraint->apply_bool(new_value, verbose);
   }
   return status;
 }
 
-JVMFlag::Error JVMFlag::boolAt(const char* name, size_t len, bool* value, bool allow_locked, bool return_flag) {
-  JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return JVMFlag::INVALID_FLAG;
-  if (!result->is_bool()) return JVMFlag::WRONG_FORMAT;
-  *value = result->get_bool();
+JVMFlag::Error JVMFlag::boolAt(const JVMFlag* flag, bool* value) {
+  if (flag == NULL) return JVMFlag::INVALID_FLAG;
+  if (!flag->is_bool()) return JVMFlag::WRONG_FORMAT;
+  *value = flag->get_bool();
   return JVMFlag::SUCCESS;
 }
 
 JVMFlag::Error JVMFlag::boolAtPut(JVMFlag* flag, bool* value, JVMFlag::Flags origin) {
-  const char* name;
   if (flag == NULL) return JVMFlag::INVALID_FLAG;
   if (!flag->is_bool()) return JVMFlag::WRONG_FORMAT;
-  name = flag->_name;
-  JVMFlag::Error check = apply_constraint_and_check_range_bool(name, *value, !JVMFlagConstraintList::validated_after_ergo());
+  JVMFlag::Error check = apply_constraint_and_check_range_bool(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
   if (check != JVMFlag::SUCCESS) return check;
   bool old_value = flag->get_bool();
-  trace_flag_changed<EventBooleanFlagChanged, bool>(name, old_value, *value, origin);
+  trace_flag_changed<EventBooleanFlagChanged, bool>(flag, old_value, *value, origin);
   check = flag->set_bool(*value);
   *value = old_value;
   flag->set_origin(origin);
   return check;
 }
 
-JVMFlag::Error JVMFlag::boolAtPut(const char* name, size_t len, bool* value, JVMFlag::Flags origin) {
-  JVMFlag* result = JVMFlag::find_flag(name, len);
-  return boolAtPut(result, value, origin);
-}
-
 JVMFlag::Error JVMFlagEx::boolAtPut(JVMFlagsEnum flag, bool value, JVMFlag::Flags origin) {
-  JVMFlag* faddr = address_of_flag(flag);
+  JVMFlag* faddr = flag_from_enum(flag);
   guarantee(faddr != NULL && faddr->is_bool(), "wrong flag type");
   return JVMFlag::boolAtPut(faddr, &value, origin);
 }
 
-static JVMFlag::Error apply_constraint_and_check_range_int(const char* name, int new_value, bool verbose) {
+static JVMFlag::Error apply_constraint_and_check_range_int(const JVMFlag* flag, int new_value, bool verbose) {
   JVMFlag::Error status = JVMFlag::SUCCESS;
-  JVMFlagRange* range = JVMFlagRangeList::find(name);
+  JVMFlagRange* range = JVMFlagRangeList::find(flag);
   if (range != NULL) {
     status = range->check_int(new_value, verbose);
   }
   if (status == JVMFlag::SUCCESS) {
-    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(name);
+    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
     if (constraint != NULL) {
       status = constraint->apply_int(new_value, verbose);
     }
@@ -1061,48 +1040,40 @@
   return status;
 }
 
-JVMFlag::Error JVMFlag::intAt(const char* name, size_t len, int* value, bool allow_locked, bool return_flag) {
-  JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return JVMFlag::INVALID_FLAG;
-  if (!result->is_int()) return JVMFlag::WRONG_FORMAT;
-  *value = result->get_int();
+JVMFlag::Error JVMFlag::intAt(const JVMFlag* flag, int* value) {
+  if (flag == NULL) return JVMFlag::INVALID_FLAG;
+  if (!flag->is_int()) return JVMFlag::WRONG_FORMAT;
+  *value = flag->get_int();
   return JVMFlag::SUCCESS;
 }
 
 JVMFlag::Error JVMFlag::intAtPut(JVMFlag* flag, int* value, JVMFlag::Flags origin) {
-  const char* name;
   if (flag == NULL) return JVMFlag::INVALID_FLAG;
   if (!flag->is_int()) return JVMFlag::WRONG_FORMAT;
-  name = flag->_name;
-  JVMFlag::Error check = apply_constraint_and_check_range_int(name, *value, !JVMFlagConstraintList::validated_after_ergo());
+  JVMFlag::Error check = apply_constraint_and_check_range_int(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
   if (check != JVMFlag::SUCCESS) return check;
   int old_value = flag->get_int();
-  trace_flag_changed<EventIntFlagChanged, s4>(name, old_value, *value, origin);
+  trace_flag_changed<EventIntFlagChanged, s4>(flag, old_value, *value, origin);
   check = flag->set_int(*value);
   *value = old_value;
   flag->set_origin(origin);
   return check;
 }
 
-JVMFlag::Error JVMFlag::intAtPut(const char* name, size_t len, int* value, JVMFlag::Flags origin) {
-  JVMFlag* result = JVMFlag::find_flag(name, len);
-  return intAtPut(result, value, origin);
-}
-
 JVMFlag::Error JVMFlagEx::intAtPut(JVMFlagsEnum flag, int value, JVMFlag::Flags origin) {
-  JVMFlag* faddr = address_of_flag(flag);
+  JVMFlag* faddr = flag_from_enum(flag);
   guarantee(faddr != NULL && faddr->is_int(), "wrong flag type");
   return JVMFlag::intAtPut(faddr, &value, origin);
 }
 
-static JVMFlag::Error apply_constraint_and_check_range_uint(const char* name, uint new_value, bool verbose) {
+static JVMFlag::Error apply_constraint_and_check_range_uint(const JVMFlag* flag, uint new_value, bool verbose) {
   JVMFlag::Error status = JVMFlag::SUCCESS;
-  JVMFlagRange* range = JVMFlagRangeList::find(name);
+  JVMFlagRange* range = JVMFlagRangeList::find(flag);
   if (range != NULL) {
     status = range->check_uint(new_value, verbose);
   }
   if (status == JVMFlag::SUCCESS) {
-    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(name);
+    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
     if (constraint != NULL) {
       status = constraint->apply_uint(new_value, verbose);
     }
@@ -1110,56 +1081,47 @@
   return status;
 }
 
-JVMFlag::Error JVMFlag::uintAt(const char* name, size_t len, uint* value, bool allow_locked, bool return_flag) {
-  JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return JVMFlag::INVALID_FLAG;
-  if (!result->is_uint()) return JVMFlag::WRONG_FORMAT;
-  *value = result->get_uint();
+JVMFlag::Error JVMFlag::uintAt(const JVMFlag* flag, uint* value) {
+  if (flag == NULL) return JVMFlag::INVALID_FLAG;
+  if (!flag->is_uint()) return JVMFlag::WRONG_FORMAT;
+  *value = flag->get_uint();
   return JVMFlag::SUCCESS;
 }
 
 JVMFlag::Error JVMFlag::uintAtPut(JVMFlag* flag, uint* value, JVMFlag::Flags origin) {
-  const char* name;
   if (flag == NULL) return JVMFlag::INVALID_FLAG;
   if (!flag->is_uint()) return JVMFlag::WRONG_FORMAT;
-  name = flag->_name;
-  JVMFlag::Error check = apply_constraint_and_check_range_uint(name, *value, !JVMFlagConstraintList::validated_after_ergo());
+  JVMFlag::Error check = apply_constraint_and_check_range_uint(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
   if (check != JVMFlag::SUCCESS) return check;
   uint old_value = flag->get_uint();
-  trace_flag_changed<EventUnsignedIntFlagChanged, u4>(name, old_value, *value, origin);
+  trace_flag_changed<EventUnsignedIntFlagChanged, u4>(flag, old_value, *value, origin);
   check = flag->set_uint(*value);
   *value = old_value;
   flag->set_origin(origin);
   return check;
 }
 
-JVMFlag::Error JVMFlag::uintAtPut(const char* name, size_t len, uint* value, JVMFlag::Flags origin) {
-  JVMFlag* result = JVMFlag::find_flag(name, len);
-  return uintAtPut(result, value, origin);
-}
-
 JVMFlag::Error JVMFlagEx::uintAtPut(JVMFlagsEnum flag, uint value, JVMFlag::Flags origin) {
-  JVMFlag* faddr = address_of_flag(flag);
+  JVMFlag* faddr = flag_from_enum(flag);
   guarantee(faddr != NULL && faddr->is_uint(), "wrong flag type");
   return JVMFlag::uintAtPut(faddr, &value, origin);
 }
 
-JVMFlag::Error JVMFlag::intxAt(const char* name, size_t len, intx* value, bool allow_locked, bool return_flag) {
-  JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return JVMFlag::INVALID_FLAG;
-  if (!result->is_intx()) return JVMFlag::WRONG_FORMAT;
-  *value = result->get_intx();
+JVMFlag::Error JVMFlag::intxAt(const JVMFlag* flag, intx* value) {
+  if (flag == NULL) return JVMFlag::INVALID_FLAG;
+  if (!flag->is_intx()) return JVMFlag::WRONG_FORMAT;
+  *value = flag->get_intx();
   return JVMFlag::SUCCESS;
 }
 
-static JVMFlag::Error apply_constraint_and_check_range_intx(const char* name, intx new_value, bool verbose) {
+static JVMFlag::Error apply_constraint_and_check_range_intx(const JVMFlag* flag, intx new_value, bool verbose) {
   JVMFlag::Error status = JVMFlag::SUCCESS;
-  JVMFlagRange* range = JVMFlagRangeList::find(name);
+  JVMFlagRange* range = JVMFlagRangeList::find(flag);
   if (range != NULL) {
     status = range->check_intx(new_value, verbose);
   }
   if (status == JVMFlag::SUCCESS) {
-    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(name);
+    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
     if (constraint != NULL) {
       status = constraint->apply_intx(new_value, verbose);
     }
@@ -1168,47 +1130,39 @@
 }
 
 JVMFlag::Error JVMFlag::intxAtPut(JVMFlag* flag, intx* value, JVMFlag::Flags origin) {
-  const char* name;
   if (flag == NULL) return JVMFlag::INVALID_FLAG;
   if (!flag->is_intx()) return JVMFlag::WRONG_FORMAT;
-  name = flag->_name;
-  JVMFlag::Error check = apply_constraint_and_check_range_intx(name, *value, !JVMFlagConstraintList::validated_after_ergo());
+  JVMFlag::Error check = apply_constraint_and_check_range_intx(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
   if (check != JVMFlag::SUCCESS) return check;
   intx old_value = flag->get_intx();
-  trace_flag_changed<EventLongFlagChanged, intx>(name, old_value, *value, origin);
+  trace_flag_changed<EventLongFlagChanged, intx>(flag, old_value, *value, origin);
   check = flag->set_intx(*value);
   *value = old_value;
   flag->set_origin(origin);
   return check;
 }
 
-JVMFlag::Error JVMFlag::intxAtPut(const char* name, size_t len, intx* value, JVMFlag::Flags origin) {
-  JVMFlag* result = JVMFlag::find_flag(name, len);
-  return intxAtPut(result, value, origin);
-}
-
 JVMFlag::Error JVMFlagEx::intxAtPut(JVMFlagsEnum flag, intx value, JVMFlag::Flags origin) {
-  JVMFlag* faddr = address_of_flag(flag);
+  JVMFlag* faddr = flag_from_enum(flag);
   guarantee(faddr != NULL && faddr->is_intx(), "wrong flag type");
   return JVMFlag::intxAtPut(faddr, &value, origin);
 }
 
-JVMFlag::Error JVMFlag::uintxAt(const char* name, size_t len, uintx* value, bool allow_locked, bool return_flag) {
-  JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return JVMFlag::INVALID_FLAG;
-  if (!result->is_uintx()) return JVMFlag::WRONG_FORMAT;
-  *value = result->get_uintx();
+JVMFlag::Error JVMFlag::uintxAt(const JVMFlag* flag, uintx* value) {
+  if (flag == NULL) return JVMFlag::INVALID_FLAG;
+  if (!flag->is_uintx()) return JVMFlag::WRONG_FORMAT;
+  *value = flag->get_uintx();
   return JVMFlag::SUCCESS;
 }
 
-static JVMFlag::Error apply_constraint_and_check_range_uintx(const char* name, uintx new_value, bool verbose) {
+static JVMFlag::Error apply_constraint_and_check_range_uintx(const JVMFlag* flag, uintx new_value, bool verbose) {
   JVMFlag::Error status = JVMFlag::SUCCESS;
-  JVMFlagRange* range = JVMFlagRangeList::find(name);
+  JVMFlagRange* range = JVMFlagRangeList::find(flag);
   if (range != NULL) {
     status = range->check_uintx(new_value, verbose);
   }
   if (status == JVMFlag::SUCCESS) {
-    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(name);
+    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
     if (constraint != NULL) {
       status = constraint->apply_uintx(new_value, verbose);
     }
@@ -1217,47 +1171,39 @@
 }
 
 JVMFlag::Error JVMFlag::uintxAtPut(JVMFlag* flag, uintx* value, JVMFlag::Flags origin) {
-  const char* name;
   if (flag == NULL) return JVMFlag::INVALID_FLAG;
   if (!flag->is_uintx()) return JVMFlag::WRONG_FORMAT;
-  name = flag->_name;
-  JVMFlag::Error check = apply_constraint_and_check_range_uintx(name, *value, !JVMFlagConstraintList::validated_after_ergo());
+  JVMFlag::Error check = apply_constraint_and_check_range_uintx(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
   if (check != JVMFlag::SUCCESS) return check;
   uintx old_value = flag->get_uintx();
-  trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
+  trace_flag_changed<EventUnsignedLongFlagChanged, u8>(flag, old_value, *value, origin);
   check = flag->set_uintx(*value);
   *value = old_value;
   flag->set_origin(origin);
   return check;
 }
 
-JVMFlag::Error JVMFlag::uintxAtPut(const char* name, size_t len, uintx* value, JVMFlag::Flags origin) {
-  JVMFlag* result = JVMFlag::find_flag(name, len);
-  return uintxAtPut(result, value, origin);
-}
-
 JVMFlag::Error JVMFlagEx::uintxAtPut(JVMFlagsEnum flag, uintx value, JVMFlag::Flags origin) {
-  JVMFlag* faddr = address_of_flag(flag);
+  JVMFlag* faddr = flag_from_enum(flag);
   guarantee(faddr != NULL && faddr->is_uintx(), "wrong flag type");
   return JVMFlag::uintxAtPut(faddr, &value, origin);
 }
 
-JVMFlag::Error JVMFlag::uint64_tAt(const char* name, size_t len, uint64_t* value, bool allow_locked, bool return_flag) {
-  JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return JVMFlag::INVALID_FLAG;
-  if (!result->is_uint64_t()) return JVMFlag::WRONG_FORMAT;
-  *value = result->get_uint64_t();
+JVMFlag::Error JVMFlag::uint64_tAt(const JVMFlag* flag, uint64_t* value) {
+  if (flag == NULL) return JVMFlag::INVALID_FLAG;
+  if (!flag->is_uint64_t()) return JVMFlag::WRONG_FORMAT;
+  *value = flag->get_uint64_t();
   return JVMFlag::SUCCESS;
 }
 
-static JVMFlag::Error apply_constraint_and_check_range_uint64_t(const char* name, uint64_t new_value, bool verbose) {
+static JVMFlag::Error apply_constraint_and_check_range_uint64_t(const JVMFlag* flag, uint64_t new_value, bool verbose) {
   JVMFlag::Error status = JVMFlag::SUCCESS;
-  JVMFlagRange* range = JVMFlagRangeList::find(name);
+  JVMFlagRange* range = JVMFlagRangeList::find(flag);
   if (range != NULL) {
     status = range->check_uint64_t(new_value, verbose);
   }
   if (status == JVMFlag::SUCCESS) {
-    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(name);
+    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
     if (constraint != NULL) {
       status = constraint->apply_uint64_t(new_value, verbose);
     }
@@ -1266,47 +1212,39 @@
 }
 
 JVMFlag::Error JVMFlag::uint64_tAtPut(JVMFlag* flag, uint64_t* value, JVMFlag::Flags origin) {
-  const char* name;
   if (flag == NULL) return JVMFlag::INVALID_FLAG;
   if (!flag->is_uint64_t()) return JVMFlag::WRONG_FORMAT;
-  name = flag->_name;
-  JVMFlag::Error check = apply_constraint_and_check_range_uint64_t(name, *value, !JVMFlagConstraintList::validated_after_ergo());
+  JVMFlag::Error check = apply_constraint_and_check_range_uint64_t(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
   if (check != JVMFlag::SUCCESS) return check;
   uint64_t old_value = flag->get_uint64_t();
-  trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
+  trace_flag_changed<EventUnsignedLongFlagChanged, u8>(flag, old_value, *value, origin);
   check = flag->set_uint64_t(*value);
   *value = old_value;
   flag->set_origin(origin);
   return check;
 }
 
-JVMFlag::Error JVMFlag::uint64_tAtPut(const char* name, size_t len, uint64_t* value, JVMFlag::Flags origin) {
-  JVMFlag* result = JVMFlag::find_flag(name, len);
-  return uint64_tAtPut(result, value, origin);
-}
-
 JVMFlag::Error JVMFlagEx::uint64_tAtPut(JVMFlagsEnum flag, uint64_t value, JVMFlag::Flags origin) {
-  JVMFlag* faddr = address_of_flag(flag);
+  JVMFlag* faddr = flag_from_enum(flag);
   guarantee(faddr != NULL && faddr->is_uint64_t(), "wrong flag type");
   return JVMFlag::uint64_tAtPut(faddr, &value, origin);
 }
 
-JVMFlag::Error JVMFlag::size_tAt(const char* name, size_t len, size_t* value, bool allow_locked, bool return_flag) {
-  JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return JVMFlag::INVALID_FLAG;
-  if (!result->is_size_t()) return JVMFlag::WRONG_FORMAT;
-  *value = result->get_size_t();
+JVMFlag::Error JVMFlag::size_tAt(const JVMFlag* flag, size_t* value) {
+  if (flag == NULL) return JVMFlag::INVALID_FLAG;
+  if (!flag->is_size_t()) return JVMFlag::WRONG_FORMAT;
+  *value = flag->get_size_t();
   return JVMFlag::SUCCESS;
 }
 
-static JVMFlag::Error apply_constraint_and_check_range_size_t(const char* name, size_t new_value, bool verbose) {
+static JVMFlag::Error apply_constraint_and_check_range_size_t(const JVMFlag* flag, size_t new_value, bool verbose) {
   JVMFlag::Error status = JVMFlag::SUCCESS;
-  JVMFlagRange* range = JVMFlagRangeList::find(name);
+  JVMFlagRange* range = JVMFlagRangeList::find(flag);
   if (range != NULL) {
     status = range->check_size_t(new_value, verbose);
   }
   if (status == JVMFlag::SUCCESS) {
-    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(name);
+    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
     if (constraint != NULL) {
       status = constraint->apply_size_t(new_value, verbose);
     }
@@ -1316,47 +1254,39 @@
 
 
 JVMFlag::Error JVMFlag::size_tAtPut(JVMFlag* flag, size_t* value, JVMFlag::Flags origin) {
-  const char* name;
   if (flag == NULL) return JVMFlag::INVALID_FLAG;
   if (!flag->is_size_t()) return JVMFlag::WRONG_FORMAT;
-  name = flag->_name;
-  JVMFlag::Error check = apply_constraint_and_check_range_size_t(name, *value, !JVMFlagConstraintList::validated_after_ergo());
+  JVMFlag::Error check = apply_constraint_and_check_range_size_t(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
   if (check != JVMFlag::SUCCESS) return check;
   size_t old_value = flag->get_size_t();
-  trace_flag_changed<EventUnsignedLongFlagChanged, u8>(name, old_value, *value, origin);
+  trace_flag_changed<EventUnsignedLongFlagChanged, u8>(flag, old_value, *value, origin);
   check = flag->set_size_t(*value);
   *value = old_value;
   flag->set_origin(origin);
   return check;
 }
 
-JVMFlag::Error JVMFlag::size_tAtPut(const char* name, size_t len, size_t* value, JVMFlag::Flags origin) {
-  JVMFlag* result = JVMFlag::find_flag(name, len);
-  return size_tAtPut(result, value, origin);
-}
-
 JVMFlag::Error JVMFlagEx::size_tAtPut(JVMFlagsEnum flag, size_t value, JVMFlag::Flags origin) {
-  JVMFlag* faddr = address_of_flag(flag);
+  JVMFlag* faddr = flag_from_enum(flag);
   guarantee(faddr != NULL && faddr->is_size_t(), "wrong flag type");
   return JVMFlag::size_tAtPut(faddr, &value, origin);
 }
 
-JVMFlag::Error JVMFlag::doubleAt(const char* name, size_t len, double* value, bool allow_locked, bool return_flag) {
-  JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return JVMFlag::INVALID_FLAG;
-  if (!result->is_double()) return JVMFlag::WRONG_FORMAT;
-  *value = result->get_double();
+JVMFlag::Error JVMFlag::doubleAt(const JVMFlag* flag, double* value) {
+  if (flag == NULL) return JVMFlag::INVALID_FLAG;
+  if (!flag->is_double()) return JVMFlag::WRONG_FORMAT;
+  *value = flag->get_double();
   return JVMFlag::SUCCESS;
 }
 
-static JVMFlag::Error apply_constraint_and_check_range_double(const char* name, double new_value, bool verbose) {
+static JVMFlag::Error apply_constraint_and_check_range_double(const JVMFlag* flag, double new_value, bool verbose) {
   JVMFlag::Error status = JVMFlag::SUCCESS;
-  JVMFlagRange* range = JVMFlagRangeList::find(name);
+  JVMFlagRange* range = JVMFlagRangeList::find(flag);
   if (range != NULL) {
     status = range->check_double(new_value, verbose);
   }
   if (status == JVMFlag::SUCCESS) {
-    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(name);
+    JVMFlagConstraint* constraint = JVMFlagConstraintList::find_if_needs_check(flag);
     if (constraint != NULL) {
       status = constraint->apply_double(new_value, verbose);
     }
@@ -1365,64 +1295,55 @@
 }
 
 JVMFlag::Error JVMFlag::doubleAtPut(JVMFlag* flag, double* value, JVMFlag::Flags origin) {
-  const char* name;
   if (flag == NULL) return JVMFlag::INVALID_FLAG;
   if (!flag->is_double()) return JVMFlag::WRONG_FORMAT;
-  name = flag->_name;
-  JVMFlag::Error check = apply_constraint_and_check_range_double(name, *value, !JVMFlagConstraintList::validated_after_ergo());
+  JVMFlag::Error check = apply_constraint_and_check_range_double(flag, *value, !JVMFlagConstraintList::validated_after_ergo());
   if (check != JVMFlag::SUCCESS) return check;
   double old_value = flag->get_double();
-  trace_flag_changed<EventDoubleFlagChanged, double>(name, old_value, *value, origin);
+  trace_flag_changed<EventDoubleFlagChanged, double>(flag, old_value, *value, origin);
   check = flag->set_double(*value);
   *value = old_value;
   flag->set_origin(origin);
   return check;
 }
 
-JVMFlag::Error JVMFlag::doubleAtPut(const char* name, size_t len, double* value, JVMFlag::Flags origin) {
-  JVMFlag* result = JVMFlag::find_flag(name, len);
-  return doubleAtPut(result, value, origin);
-}
-
 JVMFlag::Error JVMFlagEx::doubleAtPut(JVMFlagsEnum flag, double value, JVMFlag::Flags origin) {
-  JVMFlag* faddr = address_of_flag(flag);
+  JVMFlag* faddr = flag_from_enum(flag);
   guarantee(faddr != NULL && faddr->is_double(), "wrong flag type");
   return JVMFlag::doubleAtPut(faddr, &value, origin);
 }
 
-JVMFlag::Error JVMFlag::ccstrAt(const char* name, size_t len, ccstr* value, bool allow_locked, bool return_flag) {
-  JVMFlag* result = JVMFlag::find_flag(name, len, allow_locked, return_flag);
-  if (result == NULL) return JVMFlag::INVALID_FLAG;
-  if (!result->is_ccstr()) return JVMFlag::WRONG_FORMAT;
-  *value = result->get_ccstr();
+JVMFlag::Error JVMFlag::ccstrAt(const JVMFlag* flag, ccstr* value) {
+  if (flag == NULL) return JVMFlag::INVALID_FLAG;
+  if (!flag->is_ccstr()) return JVMFlag::WRONG_FORMAT;
+  *value = flag->get_ccstr();
   return JVMFlag::SUCCESS;
 }
 
-JVMFlag::Error JVMFlag::ccstrAtPut(const char* name, size_t len, ccstr* value, JVMFlag::Flags origin) {
-  JVMFlag* result = JVMFlag::find_flag(name, len);
-  if (result == NULL) return JVMFlag::INVALID_FLAG;
-  if (!result->is_ccstr()) return JVMFlag::WRONG_FORMAT;
-  ccstr old_value = result->get_ccstr();
-  trace_flag_changed<EventStringFlagChanged, const char*>(name, old_value, *value, origin);
+JVMFlag::Error JVMFlag::ccstrAtPut(JVMFlag* flag, ccstr* value, JVMFlag::Flags origin) {
+  if (flag == NULL) return JVMFlag::INVALID_FLAG;
+  if (!flag->is_ccstr()) return JVMFlag::WRONG_FORMAT;
+  ccstr old_value = flag->get_ccstr();
+  trace_flag_changed<EventStringFlagChanged, const char*>(flag, old_value, *value, origin);
   char* new_value = NULL;
   if (*value != NULL) {
     new_value = os::strdup_check_oom(*value);
   }
-  JVMFlag::Error check = result->set_ccstr(new_value);
-  if (result->is_default() && old_value != NULL) {
+  JVMFlag::Error check = flag->set_ccstr(new_value);
+  if (flag->is_default() && old_value != NULL) {
     // Prior value is NOT heap allocated, but was a literal constant.
     old_value = os::strdup_check_oom(old_value);
   }
   *value = old_value;
-  result->set_origin(origin);
+  flag->set_origin(origin);
   return check;
 }
 
 JVMFlag::Error JVMFlagEx::ccstrAtPut(JVMFlagsEnum flag, ccstr value, JVMFlag::Flags origin) {
-  JVMFlag* faddr = address_of_flag(flag);
+  JVMFlag* faddr = flag_from_enum(flag);
   guarantee(faddr != NULL && faddr->is_ccstr(), "wrong flag type");
   ccstr old_value = faddr->get_ccstr();
-  trace_flag_changed<EventStringFlagChanged, const char*>(faddr->_name, old_value, value, origin);
+  trace_flag_changed<EventStringFlagChanged, const char*>(faddr, old_value, value, origin);
   char* new_value = os::strdup_check_oom(value);
   JVMFlag::Error check = faddr->set_ccstr(new_value);
   if (!faddr->is_default() && old_value != NULL) {
--- a/src/hotspot/share/runtime/flags/jvmFlag.hpp	Mon Aug 26 09:13:38 2019 +0200
+++ b/src/hotspot/share/runtime/flags/jvmFlag.hpp	Mon Aug 26 09:15:43 2019 +0200
@@ -118,8 +118,20 @@
   // number of flags
   static size_t numFlags;
 
-  static JVMFlag* find_flag(const char* name) { return find_flag(name, strlen(name), true, true); };
-  static JVMFlag* find_flag(const char* name, size_t length, bool allow_locked = false, bool return_flag = false);
+private:
+  static JVMFlag* find_flag(const char* name, size_t length, bool allow_locked, bool return_flag);
+
+public:
+  static JVMFlag* find_flag(const char* name) {
+    return find_flag(name, strlen(name), false, false);
+  }
+  static const JVMFlag* find_declared_flag(const char* name, size_t length) {
+    return find_flag(name, length, true, true);
+  }
+  static const JVMFlag* find_declared_flag(const char* name) {
+    return find_declared_flag(name, strlen(name));
+  }
+
   static JVMFlag* fuzzy_match(const char* name, size_t length, bool allow_locked = false);
 
   static const char* get_int_default_range_str();
@@ -213,63 +225,35 @@
   static const char* flag_error_str(JVMFlag::Error error);
 
 public:
-  static JVMFlag::Error boolAt(const char* name, size_t len, bool* value, bool allow_locked = false, bool return_flag = false);
-  static JVMFlag::Error boolAt(const char* name, bool* value, bool allow_locked = false, bool return_flag = false)      { return boolAt(name, strlen(name), value, allow_locked, return_flag); }
+  static JVMFlag::Error boolAt(const JVMFlag* flag, bool* value);
   static JVMFlag::Error boolAtPut(JVMFlag* flag, bool* value, JVMFlag::Flags origin);
-  static JVMFlag::Error boolAtPut(const char* name, size_t len, bool* value, JVMFlag::Flags origin);
-  static JVMFlag::Error boolAtPut(const char* name, bool* value, JVMFlag::Flags origin)   { return boolAtPut(name, strlen(name), value, origin); }
 
-  static JVMFlag::Error intAt(const char* name, size_t len, int* value, bool allow_locked = false, bool return_flag = false);
-  static JVMFlag::Error intAt(const char* name, int* value, bool allow_locked = false, bool return_flag = false)      { return intAt(name, strlen(name), value, allow_locked, return_flag); }
+  static JVMFlag::Error intAt(const JVMFlag* flag, int* value);
   static JVMFlag::Error intAtPut(JVMFlag* flag, int* value, JVMFlag::Flags origin);
-  static JVMFlag::Error intAtPut(const char* name, size_t len, int* value, JVMFlag::Flags origin);
-  static JVMFlag::Error intAtPut(const char* name, int* value, JVMFlag::Flags origin)   { return intAtPut(name, strlen(name), value, origin); }
 
-  static JVMFlag::Error uintAt(const char* name, size_t len, uint* value, bool allow_locked = false, bool return_flag = false);
-  static JVMFlag::Error uintAt(const char* name, uint* value, bool allow_locked = false, bool return_flag = false)      { return uintAt(name, strlen(name), value, allow_locked, return_flag); }
+  static JVMFlag::Error uintAt(const JVMFlag* flag, uint* value);
   static JVMFlag::Error uintAtPut(JVMFlag* flag, uint* value, JVMFlag::Flags origin);
-  static JVMFlag::Error uintAtPut(const char* name, size_t len, uint* value, JVMFlag::Flags origin);
-  static JVMFlag::Error uintAtPut(const char* name, uint* value, JVMFlag::Flags origin)   { return uintAtPut(name, strlen(name), value, origin); }
 
-  static JVMFlag::Error intxAt(const char* name, size_t len, intx* value, bool allow_locked = false, bool return_flag = false);
-  static JVMFlag::Error intxAt(const char* name, intx* value, bool allow_locked = false, bool return_flag = false)      { return intxAt(name, strlen(name), value, allow_locked, return_flag); }
+  static JVMFlag::Error intxAt(const JVMFlag* flag, intx* value);
   static JVMFlag::Error intxAtPut(JVMFlag* flag, intx* value, JVMFlag::Flags origin);
-  static JVMFlag::Error intxAtPut(const char* name, size_t len, intx* value, JVMFlag::Flags origin);
-  static JVMFlag::Error intxAtPut(const char* name, intx* value, JVMFlag::Flags origin)   { return intxAtPut(name, strlen(name), value, origin); }
 
-  static JVMFlag::Error uintxAt(const char* name, size_t len, uintx* value, bool allow_locked = false, bool return_flag = false);
-  static JVMFlag::Error uintxAt(const char* name, uintx* value, bool allow_locked = false, bool return_flag = false)    { return uintxAt(name, strlen(name), value, allow_locked, return_flag); }
+  static JVMFlag::Error uintxAt(const JVMFlag* flag, uintx* value);
   static JVMFlag::Error uintxAtPut(JVMFlag* flag, uintx* value, JVMFlag::Flags origin);
-  static JVMFlag::Error uintxAtPut(const char* name, size_t len, uintx* value, JVMFlag::Flags origin);
-  static JVMFlag::Error uintxAtPut(const char* name, uintx* value, JVMFlag::Flags origin) { return uintxAtPut(name, strlen(name), value, origin); }
 
-  static JVMFlag::Error size_tAt(const char* name, size_t len, size_t* value, bool allow_locked = false, bool return_flag = false);
-  static JVMFlag::Error size_tAt(const char* name, size_t* value, bool allow_locked = false, bool return_flag = false)    { return size_tAt(name, strlen(name), value, allow_locked, return_flag); }
+  static JVMFlag::Error size_tAt(const JVMFlag* flag, size_t* value);
   static JVMFlag::Error size_tAtPut(JVMFlag* flag, size_t* value, JVMFlag::Flags origin);
-  static JVMFlag::Error size_tAtPut(const char* name, size_t len, size_t* value, JVMFlag::Flags origin);
-  static JVMFlag::Error size_tAtPut(const char* name, size_t* value, JVMFlag::Flags origin) { return size_tAtPut(name, strlen(name), value, origin); }
 
-  static JVMFlag::Error uint64_tAt(const char* name, size_t len, uint64_t* value, bool allow_locked = false, bool return_flag = false);
-  static JVMFlag::Error uint64_tAt(const char* name, uint64_t* value, bool allow_locked = false, bool return_flag = false) { return uint64_tAt(name, strlen(name), value, allow_locked, return_flag); }
+  static JVMFlag::Error uint64_tAt(const JVMFlag* flag, uint64_t* value);
   static JVMFlag::Error uint64_tAtPut(JVMFlag* flag, uint64_t* value, JVMFlag::Flags origin);
-  static JVMFlag::Error uint64_tAtPut(const char* name, size_t len, uint64_t* value, JVMFlag::Flags origin);
-  static JVMFlag::Error uint64_tAtPut(const char* name, uint64_t* value, JVMFlag::Flags origin) { return uint64_tAtPut(name, strlen(name), value, origin); }
 
-  static JVMFlag::Error doubleAt(const char* name, size_t len, double* value, bool allow_locked = false, bool return_flag = false);
-  static JVMFlag::Error doubleAt(const char* name, double* value, bool allow_locked = false, bool return_flag = false)    { return doubleAt(name, strlen(name), value, allow_locked, return_flag); }
+  static JVMFlag::Error doubleAt(const JVMFlag* flag, double* value);
   static JVMFlag::Error doubleAtPut(JVMFlag* flag, double* value, JVMFlag::Flags origin);
-  static JVMFlag::Error doubleAtPut(const char* name, size_t len, double* value, JVMFlag::Flags origin);
-  static JVMFlag::Error doubleAtPut(const char* name, double* value, JVMFlag::Flags origin) { return doubleAtPut(name, strlen(name), value, origin); }
 
-  static JVMFlag::Error ccstrAt(const char* name, size_t len, ccstr* value, bool allow_locked = false, bool return_flag = false);
-  static JVMFlag::Error ccstrAt(const char* name, ccstr* value, bool allow_locked = false, bool return_flag = false)    { return ccstrAt(name, strlen(name), value, allow_locked, return_flag); }
+  static JVMFlag::Error ccstrAt(const JVMFlag* flag, ccstr* value);
   // Contract:  JVMFlag will make private copy of the incoming value.
   // Outgoing value is always malloc-ed, and caller MUST call free.
-  static JVMFlag::Error ccstrAtPut(const char* name, size_t len, ccstr* value, JVMFlag::Flags origin);
-  static JVMFlag::Error ccstrAtPut(const char* name, ccstr* value, JVMFlag::Flags origin) { return ccstrAtPut(name, strlen(name), value, origin); }
+  static JVMFlag::Error ccstrAtPut(JVMFlag* flag, ccstr* value, JVMFlag::Flags origin);
 
-  // Returns false if name is not a command line flag.
-  static bool wasSetOnCmdline(const char* name, bool* value);
   static void printSetFlags(outputStream* out);
 
   // printRanges will print out flags type, name and range values as expected by -XX:+PrintFlagsRanges
--- a/src/hotspot/share/runtime/flags/jvmFlagConstraintList.cpp	Mon Aug 26 09:13:38 2019 +0200
+++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintList.cpp	Mon Aug 26 09:15:43 2019 +0200
@@ -32,22 +32,20 @@
 #include "runtime/flags/jvmFlagConstraintsCompiler.hpp"
 #include "runtime/flags/jvmFlagConstraintsRuntime.hpp"
 #include "runtime/globals.hpp"
+#include "runtime/globals_extension.hpp"
 #include "runtime/os.hpp"
 #include "utilities/macros.hpp"
 
 class JVMFlagConstraint_bool : public JVMFlagConstraint {
   JVMFlagConstraintFunc_bool _constraint;
-  const bool* _ptr;
 
 public:
-  // the "name" argument must be a string literal
-  JVMFlagConstraint_bool(const char* name, const bool* ptr,
-                                 JVMFlagConstraintFunc_bool func,
-                                 ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
+  JVMFlagConstraint_bool(const JVMFlag* flag,
+                         JVMFlagConstraintFunc_bool func,
+                         ConstraintType type) : JVMFlagConstraint(flag, type), _constraint(func) {}
 
   JVMFlag::Error apply(bool verbose) {
-    bool value = *_ptr;
-    return _constraint(value, verbose);
+    return _constraint(_flag->get_bool(), verbose);
   }
 
   JVMFlag::Error apply_bool(bool value, bool verbose) {
@@ -57,17 +55,14 @@
 
 class JVMFlagConstraint_int : public JVMFlagConstraint {
   JVMFlagConstraintFunc_int _constraint;
-  const int* _ptr;
 
 public:
-  // the "name" argument must be a string literal
-  JVMFlagConstraint_int(const char* name, const int* ptr,
-                                JVMFlagConstraintFunc_int func,
-                                ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
+  JVMFlagConstraint_int(const JVMFlag* flag,
+                        JVMFlagConstraintFunc_int func,
+                        ConstraintType type) : JVMFlagConstraint(flag, type), _constraint(func) {}
 
   JVMFlag::Error apply(bool verbose) {
-    int value = *_ptr;
-    return _constraint(value, verbose);
+    return _constraint(_flag->get_int(), verbose);
   }
 
   JVMFlag::Error apply_int(int value, bool verbose) {
@@ -77,17 +72,14 @@
 
 class JVMFlagConstraint_intx : public JVMFlagConstraint {
   JVMFlagConstraintFunc_intx _constraint;
-  const intx* _ptr;
 
 public:
-  // the "name" argument must be a string literal
-  JVMFlagConstraint_intx(const char* name, const intx* ptr,
-                                 JVMFlagConstraintFunc_intx func,
-                                 ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
+  JVMFlagConstraint_intx(const JVMFlag* flag,
+                         JVMFlagConstraintFunc_intx func,
+                         ConstraintType type) : JVMFlagConstraint(flag, type), _constraint(func) {}
 
   JVMFlag::Error apply(bool verbose) {
-    intx value = *_ptr;
-    return _constraint(value, verbose);
+    return _constraint(_flag->get_intx(), verbose);
   }
 
   JVMFlag::Error apply_intx(intx value, bool verbose) {
@@ -97,17 +89,14 @@
 
 class JVMFlagConstraint_uint : public JVMFlagConstraint {
   JVMFlagConstraintFunc_uint _constraint;
-  const uint* _ptr;
 
 public:
-  // the "name" argument must be a string literal
-  JVMFlagConstraint_uint(const char* name, const uint* ptr,
-                                 JVMFlagConstraintFunc_uint func,
-                                 ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
+  JVMFlagConstraint_uint(const JVMFlag* flag,
+                         JVMFlagConstraintFunc_uint func,
+                         ConstraintType type) : JVMFlagConstraint(flag, type), _constraint(func) {}
 
   JVMFlag::Error apply(bool verbose) {
-    uint value = *_ptr;
-    return _constraint(value, verbose);
+    return _constraint(_flag->get_uint(), verbose);
   }
 
   JVMFlag::Error apply_uint(uint value, bool verbose) {
@@ -117,17 +106,14 @@
 
 class JVMFlagConstraint_uintx : public JVMFlagConstraint {
   JVMFlagConstraintFunc_uintx _constraint;
-  const uintx* _ptr;
 
 public:
-  // the "name" argument must be a string literal
-  JVMFlagConstraint_uintx(const char* name, const uintx* ptr,
-                                  JVMFlagConstraintFunc_uintx func,
-                                 ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
+  JVMFlagConstraint_uintx(const JVMFlag* flag,
+                          JVMFlagConstraintFunc_uintx func,
+                          ConstraintType type) : JVMFlagConstraint(flag, type), _constraint(func) {}
 
   JVMFlag::Error apply(bool verbose) {
-    uintx value = *_ptr;
-    return _constraint(value, verbose);
+    return _constraint(_flag->get_uintx(), verbose);
   }
 
   JVMFlag::Error apply_uintx(uintx value, bool verbose) {
@@ -137,17 +123,14 @@
 
 class JVMFlagConstraint_uint64_t : public JVMFlagConstraint {
   JVMFlagConstraintFunc_uint64_t _constraint;
-  const uint64_t* _ptr;
 
 public:
-  // the "name" argument must be a string literal
-  JVMFlagConstraint_uint64_t(const char* name, const uint64_t* ptr,
-                                     JVMFlagConstraintFunc_uint64_t func,
-                                 ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
+  JVMFlagConstraint_uint64_t(const JVMFlag* flag,
+                             JVMFlagConstraintFunc_uint64_t func,
+                             ConstraintType type) : JVMFlagConstraint(flag, type), _constraint(func) {}
 
   JVMFlag::Error apply(bool verbose) {
-    uint64_t value = *_ptr;
-    return _constraint(value, verbose);
+    return _constraint(_flag->get_uint64_t(), verbose);
   }
 
   JVMFlag::Error apply_uint64_t(uint64_t value, bool verbose) {
@@ -157,16 +140,14 @@
 
 class JVMFlagConstraint_size_t : public JVMFlagConstraint {
   JVMFlagConstraintFunc_size_t _constraint;
-  const size_t* _ptr;
+
 public:
-  // the "name" argument must be a string literal
-  JVMFlagConstraint_size_t(const char* name, const size_t* ptr,
-                                   JVMFlagConstraintFunc_size_t func,
-                                 ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
+  JVMFlagConstraint_size_t(const JVMFlag* flag,
+                           JVMFlagConstraintFunc_size_t func,
+                           ConstraintType type) : JVMFlagConstraint(flag, type), _constraint(func) {}
 
   JVMFlag::Error apply(bool verbose) {
-    size_t value = *_ptr;
-    return _constraint(value, verbose);
+    return _constraint(_flag->get_size_t(), verbose);
   }
 
   JVMFlag::Error apply_size_t(size_t value, bool verbose) {
@@ -176,17 +157,14 @@
 
 class JVMFlagConstraint_double : public JVMFlagConstraint {
   JVMFlagConstraintFunc_double _constraint;
-  const double* _ptr;
 
 public:
-  // the "name" argument must be a string literal
-  JVMFlagConstraint_double(const char* name, const double* ptr,
-                                   JVMFlagConstraintFunc_double func,
-                                 ConstraintType type) : JVMFlagConstraint(name, type), _constraint(func), _ptr(ptr) {}
+  JVMFlagConstraint_double(const JVMFlag* flag,
+                           JVMFlagConstraintFunc_double func,
+                           ConstraintType type) : JVMFlagConstraint(flag, type), _constraint(func) {}
 
   JVMFlag::Error apply(bool verbose) {
-    double value = *_ptr;
-    return _constraint(value, verbose);
+    return _constraint(_flag->get_double(), verbose);
   }
 
   JVMFlag::Error apply_double(double value, bool verbose) {
@@ -195,49 +173,49 @@
 };
 
 // No constraint emitting
-void emit_constraint_no(...)                                                      { /* NOP */ }
+void emit_constraint_no(...)                            { /* NOP */ }
 
 // No constraint emitting if function argument is NOT provided
-void emit_constraint_bool(const char* /*name*/, const bool* /*value*/)            { /* NOP */ }
-void emit_constraint_ccstr(const char* /*name*/, const ccstr* /*value*/)          { /* NOP */ }
-void emit_constraint_ccstrlist(const char* /*name*/, const ccstrlist* /*value*/)  { /* NOP */ }
-void emit_constraint_int(const char* /*name*/, const int* /*value*/)              { /* NOP */ }
-void emit_constraint_intx(const char* /*name*/, const intx* /*value*/)            { /* NOP */ }
-void emit_constraint_uint(const char* /*name*/, const uint* /*value*/)            { /* NOP */ }
-void emit_constraint_uintx(const char* /*name*/, const uintx* /*value*/)          { /* NOP */ }
-void emit_constraint_uint64_t(const char* /*name*/, const uint64_t* /*value*/)    { /* NOP */ }
-void emit_constraint_size_t(const char* /*name*/, const size_t* /*value*/)        { /* NOP */ }
-void emit_constraint_double(const char* /*name*/, const double* /*value*/)        { /* NOP */ }
+void emit_constraint_bool(const JVMFlag* /*flag*/)      { /* NOP */ }
+void emit_constraint_ccstr(const JVMFlag* /*flag*/)     { /* NOP */ }
+void emit_constraint_ccstrlist(const JVMFlag* /*flag*/) { /* NOP */ }
+void emit_constraint_int(const JVMFlag* /*flag*/)       { /* NOP */ }
+void emit_constraint_intx(const JVMFlag* /*flag*/)      { /* NOP */ }
+void emit_constraint_uint(const JVMFlag* /*flag*/)      { /* NOP */ }
+void emit_constraint_uintx(const JVMFlag* /*flag*/)     { /* NOP */ }
+void emit_constraint_uint64_t(const JVMFlag* /*flag*/)  { /* NOP */ }
+void emit_constraint_size_t(const JVMFlag* /*flag*/)    { /* NOP */ }
+void emit_constraint_double(const JVMFlag* /*flag*/)    { /* NOP */ }
 
 // JVMFlagConstraint emitting code functions if function argument is provided
-void emit_constraint_bool(const char* name, const bool* ptr, JVMFlagConstraintFunc_bool func, JVMFlagConstraint::ConstraintType type) {
-  JVMFlagConstraintList::add(new JVMFlagConstraint_bool(name, ptr, func, type));
+void emit_constraint_bool(const JVMFlag* flag, JVMFlagConstraintFunc_bool func, JVMFlagConstraint::ConstraintType type) {
+  JVMFlagConstraintList::add(new JVMFlagConstraint_bool(flag, func, type));
 }
-void emit_constraint_int(const char* name, const int* ptr, JVMFlagConstraintFunc_int func, JVMFlagConstraint::ConstraintType type) {
-  JVMFlagConstraintList::add(new JVMFlagConstraint_int(name, ptr, func, type));
+void emit_constraint_int(const JVMFlag* flag, JVMFlagConstraintFunc_int func, JVMFlagConstraint::ConstraintType type) {
+  JVMFlagConstraintList::add(new JVMFlagConstraint_int(flag, func, type));
 }
-void emit_constraint_intx(const char* name, const intx* ptr, JVMFlagConstraintFunc_intx func, JVMFlagConstraint::ConstraintType type) {
-  JVMFlagConstraintList::add(new JVMFlagConstraint_intx(name, ptr, func, type));
+void emit_constraint_intx(const JVMFlag* flag, JVMFlagConstraintFunc_intx func, JVMFlagConstraint::ConstraintType type) {
+  JVMFlagConstraintList::add(new JVMFlagConstraint_intx(flag, func, type));
 }
-void emit_constraint_uint(const char* name, const uint* ptr, JVMFlagConstraintFunc_uint func, JVMFlagConstraint::ConstraintType type) {
-  JVMFlagConstraintList::add(new JVMFlagConstraint_uint(name, ptr, func, type));
+void emit_constraint_uint(const JVMFlag* flag, JVMFlagConstraintFunc_uint func, JVMFlagConstraint::ConstraintType type) {
+  JVMFlagConstraintList::add(new JVMFlagConstraint_uint(flag, func, type));
 }
-void emit_constraint_uintx(const char* name, const uintx* ptr, JVMFlagConstraintFunc_uintx func, JVMFlagConstraint::ConstraintType type) {
-  JVMFlagConstraintList::add(new JVMFlagConstraint_uintx(name, ptr, func, type));
+void emit_constraint_uintx(const JVMFlag* flag, JVMFlagConstraintFunc_uintx func, JVMFlagConstraint::ConstraintType type) {
+  JVMFlagConstraintList::add(new JVMFlagConstraint_uintx(flag, func, type));
 }
-void emit_constraint_uint64_t(const char* name, const uint64_t* ptr, JVMFlagConstraintFunc_uint64_t func, JVMFlagConstraint::ConstraintType type) {
-  JVMFlagConstraintList::add(new JVMFlagConstraint_uint64_t(name, ptr, func, type));
+void emit_constraint_uint64_t(const JVMFlag* flag, JVMFlagConstraintFunc_uint64_t func, JVMFlagConstraint::ConstraintType type) {
+  JVMFlagConstraintList::add(new JVMFlagConstraint_uint64_t(flag, func, type));
 }
-void emit_constraint_size_t(const char* name, const size_t* ptr, JVMFlagConstraintFunc_size_t func, JVMFlagConstraint::ConstraintType type) {
-  JVMFlagConstraintList::add(new JVMFlagConstraint_size_t(name, ptr, func, type));
+void emit_constraint_size_t(const JVMFlag* flag, JVMFlagConstraintFunc_size_t func, JVMFlagConstraint::ConstraintType type) {
+  JVMFlagConstraintList::add(new JVMFlagConstraint_size_t(flag, func, type));
 }
-void emit_constraint_double(const char* name, const double* ptr, JVMFlagConstraintFunc_double func, JVMFlagConstraint::ConstraintType type) {
-  JVMFlagConstraintList::add(new JVMFlagConstraint_double(name, ptr, func, type));
+void emit_constraint_double(const JVMFlag* flag, JVMFlagConstraintFunc_double func, JVMFlagConstraint::ConstraintType type) {
+  JVMFlagConstraintList::add(new JVMFlagConstraint_double(flag, func, type));
 }
 
 // Generate code to call emit_constraint_xxx function
 #define EMIT_CONSTRAINT_START       (void)(0
-#define EMIT_CONSTRAINT(type, name) ); emit_constraint_##type(#name, &name
+#define EMIT_CONSTRAINT(type, name) ); emit_constraint_##type(JVMFlagEx::flag_from_enum(FLAG_MEMBER_ENUM(name))
 #define EMIT_CONSTRAINT_NO          ); emit_constraint_no(0
 #define EMIT_CONSTRAINT_PRODUCT_FLAG(type, name, value, doc)      EMIT_CONSTRAINT(type, name)
 #define EMIT_CONSTRAINT_DIAGNOSTIC_FLAG(type, name, value, doc)   EMIT_CONSTRAINT(type, name)
@@ -296,11 +274,11 @@
   EMIT_CONSTRAINT_END
 }
 
-JVMFlagConstraint* JVMFlagConstraintList::find(const char* name) {
+JVMFlagConstraint* JVMFlagConstraintList::find(const JVMFlag* flag) {
   JVMFlagConstraint* found = NULL;
   for (int i=0; i<length(); i++) {
     JVMFlagConstraint* constraint = at(i);
-    if (strcmp(constraint->name(), name) == 0) {
+    if (constraint->flag() == flag) {
       found = constraint;
       break;
     }
@@ -308,11 +286,11 @@
   return found;
 }
 
-// Find constraints by name and return only if found constraint's type is equal or lower than current validating type.
-JVMFlagConstraint* JVMFlagConstraintList::find_if_needs_check(const char* name) {
+// Find constraints and return only if found constraint's type is equal or lower than current validating type.
+JVMFlagConstraint* JVMFlagConstraintList::find_if_needs_check(const JVMFlag* flag) {
   JVMFlagConstraint* found = NULL;
-  JVMFlagConstraint* constraint = find(name);
-  if (constraint && (constraint->type() <= _validating_type)) {
+  JVMFlagConstraint* constraint = find(flag);
+  if (constraint != NULL && (constraint->type() <= _validating_type)) {
     found = constraint;
   }
   return found;
--- a/src/hotspot/share/runtime/flags/jvmFlagConstraintList.hpp	Mon Aug 26 09:13:38 2019 +0200
+++ b/src/hotspot/share/runtime/flags/jvmFlagConstraintList.hpp	Mon Aug 26 09:15:43 2019 +0200
@@ -60,15 +60,17 @@
     AfterMemoryInit = 2
   };
 
+protected:
+  const JVMFlag* const _flag;
+
 private:
-  const char* _name;
   ConstraintType _validate_type;
 
 public:
   // the "name" argument must be a string literal
-  JVMFlagConstraint(const char* name, ConstraintType type) { _name=name; _validate_type=type; };
-  ~JVMFlagConstraint() {};
-  const char* name() const { return _name; }
+  JVMFlagConstraint(const JVMFlag* flag, ConstraintType type) : _flag(flag), _validate_type(type) {}
+  ~JVMFlagConstraint() {}
+  const JVMFlag* flag() const { return _flag; }
   ConstraintType type() const { return _validate_type; }
   virtual JVMFlag::Error apply(bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
   virtual JVMFlag::Error apply_bool(bool value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; };
@@ -90,8 +92,8 @@
   static void init();
   static int length() { return (_constraints != NULL) ? _constraints->length() : 0; }
   static JVMFlagConstraint* at(int i) { return (_constraints != NULL) ? _constraints->at(i) : NULL; }
-  static JVMFlagConstraint* find(const char* name);
-  static JVMFlagConstraint* find_if_needs_check(const char* name);
+  static JVMFlagConstraint* find(const JVMFlag* flag);
+  static JVMFlagConstraint* find_if_needs_check(const JVMFlag* flag);
   static void add(JVMFlagConstraint* constraint) { _constraints->append(constraint); }
   // True if 'AfterErgo' or later constraint functions are validated.
   static bool validated_after_ergo() { return _validating_type >= JVMFlagConstraint::AfterErgo; };
--- a/src/hotspot/share/runtime/flags/jvmFlagRangeList.cpp	Mon Aug 26 09:13:38 2019 +0200
+++ b/src/hotspot/share/runtime/flags/jvmFlagRangeList.cpp	Mon Aug 26 09:15:43 2019 +0200
@@ -33,6 +33,7 @@
 #include "runtime/flags/jvmFlagConstraintList.hpp"
 #include "runtime/flags/jvmFlagRangeList.hpp"
 #include "runtime/globals.hpp"
+#include "runtime/globals_extension.hpp"
 #include "runtime/os.hpp"
 #include "runtime/task.hpp"
 #include "utilities/macros.hpp"
@@ -40,15 +41,13 @@
 class JVMFlagRange_int : public JVMFlagRange {
   int _min;
   int _max;
-  const int* _ptr;
 
 public:
-  // the "name" argument must be a string literal
-  JVMFlagRange_int(const char* name, const int* ptr, int min, int max)
-    : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
+  JVMFlagRange_int(const JVMFlag* flag, int min, int max)
+    : JVMFlagRange(flag), _min(min), _max(max) {}
 
   JVMFlag::Error check(bool verbose = true) {
-    return check_int(*_ptr, verbose);
+    return check_int(_flag->get_int(), verbose);
   }
 
   JVMFlag::Error check_int(int value, bool verbose = true) {
@@ -71,14 +70,13 @@
 class JVMFlagRange_intx : public JVMFlagRange {
   intx _min;
   intx _max;
-  const intx* _ptr;
+
 public:
-  // the "name" argument must be a string literal
-  JVMFlagRange_intx(const char* name, const intx* ptr, intx min, intx max)
-    : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
+  JVMFlagRange_intx(const JVMFlag* flag, intx min, intx max)
+    : JVMFlagRange(flag), _min(min), _max(max) {}
 
   JVMFlag::Error check(bool verbose = true) {
-    return check_intx(*_ptr, verbose);
+    return check_intx(_flag->get_intx(), verbose);
   }
 
   JVMFlag::Error check_intx(intx value, bool verbose = true) {
@@ -101,15 +99,13 @@
 class JVMFlagRange_uint : public JVMFlagRange {
   uint _min;
   uint _max;
-  const uint* _ptr;
 
 public:
-  // the "name" argument must be a string literal
-  JVMFlagRange_uint(const char* name, const uint* ptr, uint min, uint max)
-    : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
+  JVMFlagRange_uint(const JVMFlag* flag, uint min, uint max)
+    : JVMFlagRange(flag), _min(min), _max(max) {}
 
   JVMFlag::Error check(bool verbose = true) {
-    return check_uint(*_ptr, verbose);
+    return check_uint(_flag->get_uint(), verbose);
   }
 
   JVMFlag::Error check_uint(uint value, bool verbose = true) {
@@ -132,15 +128,13 @@
 class JVMFlagRange_uintx : public JVMFlagRange {
   uintx _min;
   uintx _max;
-  const uintx* _ptr;
 
 public:
-  // the "name" argument must be a string literal
-  JVMFlagRange_uintx(const char* name, const uintx* ptr, uintx min, uintx max)
-    : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
+  JVMFlagRange_uintx(const JVMFlag* flag, uintx min, uintx max)
+    : JVMFlagRange(flag), _min(min), _max(max) {}
 
   JVMFlag::Error check(bool verbose = true) {
-    return check_uintx(*_ptr, verbose);
+    return check_uintx(_flag->get_uintx(), verbose);
   }
 
   JVMFlag::Error check_uintx(uintx value, bool verbose = true) {
@@ -163,15 +157,13 @@
 class JVMFlagRange_uint64_t : public JVMFlagRange {
   uint64_t _min;
   uint64_t _max;
-  const uint64_t* _ptr;
 
 public:
-  // the "name" argument must be a string literal
-  JVMFlagRange_uint64_t(const char* name, const uint64_t* ptr, uint64_t min, uint64_t max)
-    : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
+  JVMFlagRange_uint64_t(const JVMFlag* flag, uint64_t min, uint64_t max)
+    : JVMFlagRange(flag), _min(min), _max(max) {}
 
   JVMFlag::Error check(bool verbose = true) {
-    return check_uint64_t(*_ptr, verbose);
+    return check_uint64_t(_flag->get_uintx(), verbose);
   }
 
   JVMFlag::Error check_uint64_t(uint64_t value, bool verbose = true) {
@@ -194,15 +186,13 @@
 class JVMFlagRange_size_t : public JVMFlagRange {
   size_t _min;
   size_t _max;
-  const size_t* _ptr;
 
 public:
-  // the "name" argument must be a string literal
-  JVMFlagRange_size_t(const char* name, const size_t* ptr, size_t min, size_t max)
-    : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
+  JVMFlagRange_size_t(const JVMFlag* flag, size_t min, size_t max)
+    : JVMFlagRange(flag), _min(min), _max(max) {}
 
   JVMFlag::Error check(bool verbose = true) {
-    return check_size_t(*_ptr, verbose);
+    return check_size_t(_flag->get_size_t(), verbose);
   }
 
   JVMFlag::Error check_size_t(size_t value, bool verbose = true) {
@@ -225,15 +215,13 @@
 class JVMFlagRange_double : public JVMFlagRange {
   double _min;
   double _max;
-  const double* _ptr;
 
 public:
-  // the "name" argument must be a string literal
-  JVMFlagRange_double(const char* name, const double* ptr, double min, double max)
-    : JVMFlagRange(name), _min(min), _max(max), _ptr(ptr) {}
+  JVMFlagRange_double(const JVMFlag* flag, double min, double max)
+    : JVMFlagRange(flag), _min(min), _max(max) {}
 
   JVMFlag::Error check(bool verbose = true) {
-    return check_double(*_ptr, verbose);
+    return check_double(_flag->get_double(), verbose);
   }
 
   JVMFlag::Error check_double(double value, bool verbose = true) {
@@ -257,43 +245,43 @@
 void emit_range_no(...)                         { /* NOP */ }
 
 // No constraint emitting if function argument is NOT provided
-void emit_range_bool(const char* /*name*/, const bool* /*value*/)            { /* NOP */ }
-void emit_range_ccstr(const char* /*name*/, const ccstr* /*value*/)          { /* NOP */ }
-void emit_range_ccstrlist(const char* /*name*/, const ccstrlist* /*value*/)  { /* NOP */ }
-void emit_range_int(const char* /*name*/, const int* /*value*/)              { /* NOP */ }
-void emit_range_intx(const char* /*name*/, const intx* /*value*/)            { /* NOP */ }
-void emit_range_uint(const char* /*name*/, const uint* /*value*/)            { /* NOP */ }
-void emit_range_uintx(const char* /*name*/, const uintx* /*value*/)          { /* NOP */ }
-void emit_range_uint64_t(const char* /*name*/, const uint64_t* /*value*/)    { /* NOP */ }
-void emit_range_size_t(const char* /*name*/, const size_t* /*value*/)        { /* NOP */ }
-void emit_range_double(const char* /*name*/, const double* /*value*/)        { /* NOP */ }
+void emit_range_bool(const JVMFlag* /*flag*/)      { /* NOP */ }
+void emit_range_ccstr(const JVMFlag* /*flag*/)     { /* NOP */ }
+void emit_range_ccstrlist(const JVMFlag* /*flag*/) { /* NOP */ }
+void emit_range_int(const JVMFlag* /*flag*/)       { /* NOP */ }
+void emit_range_intx(const JVMFlag* /*flag*/)      { /* NOP */ }
+void emit_range_uint(const JVMFlag* /*flag*/)      { /* NOP */ }
+void emit_range_uintx(const JVMFlag* /*flag*/)     { /* NOP */ }
+void emit_range_uint64_t(const JVMFlag* /*flag*/)  { /* NOP */ }
+void emit_range_size_t(const JVMFlag* /*flag*/)    { /* NOP */ }
+void emit_range_double(const JVMFlag* /*flag*/)    { /* NOP */ }
 
 // JVMFlagRange emitting code functions if range arguments are provided
-void emit_range_int(const char* name, const int* ptr, int min, int max)       {
-  JVMFlagRangeList::add(new JVMFlagRange_int(name, ptr, min, max));
+void emit_range_int(const JVMFlag* flag, int min, int max)       {
+  JVMFlagRangeList::add(new JVMFlagRange_int(flag, min, max));
 }
-void emit_range_intx(const char* name, const intx* ptr, intx min, intx max) {
-  JVMFlagRangeList::add(new JVMFlagRange_intx(name, ptr, min, max));
+void emit_range_intx(const JVMFlag* flag, intx min, intx max) {
+  JVMFlagRangeList::add(new JVMFlagRange_intx(flag, min, max));
 }
-void emit_range_uint(const char* name, const uint* ptr, uint min, uint max) {
-  JVMFlagRangeList::add(new JVMFlagRange_uint(name, ptr, min, max));
+void emit_range_uint(const JVMFlag* flag, uint min, uint max) {
+  JVMFlagRangeList::add(new JVMFlagRange_uint(flag, min, max));
 }
-void emit_range_uintx(const char* name, const uintx* ptr, uintx min, uintx max) {
-  JVMFlagRangeList::add(new JVMFlagRange_uintx(name, ptr, min, max));
+void emit_range_uintx(const JVMFlag* flag, uintx min, uintx max) {
+  JVMFlagRangeList::add(new JVMFlagRange_uintx(flag, min, max));
 }
-void emit_range_uint64_t(const char* name, const uint64_t* ptr, uint64_t min, uint64_t max) {
-  JVMFlagRangeList::add(new JVMFlagRange_uint64_t(name, ptr, min, max));
+void emit_range_uint64_t(const JVMFlag* flag, uint64_t min, uint64_t max) {
+  JVMFlagRangeList::add(new JVMFlagRange_uint64_t(flag, min, max));
 }
-void emit_range_size_t(const char* name, const size_t* ptr, size_t min, size_t max) {
-  JVMFlagRangeList::add(new JVMFlagRange_size_t(name, ptr, min, max));
+void emit_range_size_t(const JVMFlag* flag, size_t min, size_t max) {
+  JVMFlagRangeList::add(new JVMFlagRange_size_t(flag, min, max));
 }
-void emit_range_double(const char* name, const double* ptr, double min, double max) {
-  JVMFlagRangeList::add(new JVMFlagRange_double(name, ptr, min, max));
+void emit_range_double(const JVMFlag* flag, double min, double max) {
+  JVMFlagRangeList::add(new JVMFlagRange_double(flag, min, max));
 }
 
 // Generate code to call emit_range_xxx function
 #define EMIT_RANGE_START       (void)(0
-#define EMIT_RANGE(type, name) ); emit_range_##type(#name, &name
+#define EMIT_RANGE(type, name) ); emit_range_##type(JVMFlagEx::flag_from_enum(FLAG_MEMBER_ENUM(name))
 #define EMIT_RANGE_NO          ); emit_range_no(0
 #define EMIT_RANGE_PRODUCT_FLAG(type, name, value, doc)      EMIT_RANGE(type, name)
 #define EMIT_RANGE_DIAGNOSTIC_FLAG(type, name, value, doc)   EMIT_RANGE(type, name)
@@ -351,11 +339,11 @@
   EMIT_RANGE_END
 }
 
-JVMFlagRange* JVMFlagRangeList::find(const char* name) {
+JVMFlagRange* JVMFlagRangeList::find(const JVMFlag* flag) {
   JVMFlagRange* found = NULL;
   for (int i=0; i<length(); i++) {
     JVMFlagRange* range = at(i);
-    if (strcmp(range->name(), name) == 0) {
+    if (range->flag() == flag) {
       found = range;
       break;
     }
@@ -363,12 +351,12 @@
   return found;
 }
 
-void JVMFlagRangeList::print(outputStream* st, const char* name, RangeStrFunc default_range_str_func) {
-  JVMFlagRange* range = JVMFlagRangeList::find(name);
+void JVMFlagRangeList::print(outputStream* st, const JVMFlag* flag, RangeStrFunc default_range_str_func) {
+  JVMFlagRange* range = JVMFlagRangeList::find(flag);
   if (range != NULL) {
     range->print(st);
   } else {
-    JVMFlagConstraint* constraint = JVMFlagConstraintList::find(name);
+    JVMFlagConstraint* constraint = JVMFlagConstraintList::find(flag);
     if (constraint != NULL) {
       assert(default_range_str_func!=NULL, "default_range_str_func must be provided");
       st->print("%s", default_range_str_func());
--- a/src/hotspot/share/runtime/flags/jvmFlagRangeList.hpp	Mon Aug 26 09:13:38 2019 +0200
+++ b/src/hotspot/share/runtime/flags/jvmFlagRangeList.hpp	Mon Aug 26 09:15:43 2019 +0200
@@ -39,13 +39,14 @@
  */
 
 class JVMFlagRange : public CHeapObj<mtArguments> {
-private:
-  const char* _name;
+protected:
+  const JVMFlag* const _flag;
 public:
   // the "name" argument must be a string literal
-  JVMFlagRange(const char* name) { _name=name; }
+  JVMFlagRange(const JVMFlag* flag) : _flag(flag) {}
   ~JVMFlagRange() {}
-  const char* name() { return _name; }
+  const JVMFlag* flag() const { return _flag; }
+  const char* name() const { return _flag->_name; }
   virtual JVMFlag::Error check(bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
   virtual JVMFlag::Error check_int(int value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
   virtual JVMFlag::Error check_intx(intx value, bool verbose = true) { ShouldNotReachHere(); return JVMFlag::ERR_OTHER; }
@@ -63,9 +64,9 @@
   static void init();
   static int length() { return (_ranges != NULL) ? _ranges->length() : 0; }
   static JVMFlagRange* at(int i) { return (_ranges != NULL) ? _ranges->at(i) : NULL; }
-  static JVMFlagRange* find(const char* name);
+  static JVMFlagRange* find(const JVMFlag* flag);
   static void add(JVMFlagRange* range) { _ranges->append(range); }
-  static void print(outputStream* st, const char* name, RangeStrFunc default_range_str_func);
+  static void print(outputStream* st, const JVMFlag* flag, RangeStrFunc default_range_str_func);
   // Check the final values of all flags for ranges.
   static bool check_ranges();
 };
--- a/src/hotspot/share/runtime/globals_extension.hpp	Mon Aug 26 09:13:38 2019 +0200
+++ b/src/hotspot/share/runtime/globals_extension.hpp	Mon Aug 26 09:15:43 2019 +0200
@@ -91,6 +91,8 @@
   static bool is_cmdline(JVMFlagsEnum flag);
 
   static void setOnCmdLine(JVMFlagsEnum flag);
+
+  static JVMFlag* flag_from_enum(JVMFlagsEnum flag);
 };
 
 // Construct set functions for all flags
--- a/src/hotspot/share/services/attachListener.cpp	Mon Aug 26 09:13:38 2019 +0200
+++ b/src/hotspot/share/services/attachListener.cpp	Mon Aug 26 09:15:43 2019 +0200
@@ -331,7 +331,7 @@
     out->print_cr("flag name is missing");
     return JNI_ERR;
   }
-  JVMFlag* f = JVMFlag::find_flag((char*)name, strlen(name));
+  JVMFlag* f = JVMFlag::find_flag(name);
   if (f) {
     f->print_as_flag(out);
     out->cr();
--- a/src/hotspot/share/services/dtraceAttacher.cpp	Mon Aug 26 09:13:38 2019 +0200
+++ b/src/hotspot/share/services/dtraceAttacher.cpp	Mon Aug 26 09:15:43 2019 +0200
@@ -50,9 +50,9 @@
   }
 };
 
-static void set_bool_flag(const char* flag, bool value) {
-  JVMFlag::boolAtPut((char*)flag, strlen(flag), &value,
-                              JVMFlag::ATTACH_ON_DEMAND);
+static void set_bool_flag(const char* name, bool value) {
+  JVMFlag* flag = JVMFlag::find_flag(name);
+  JVMFlag::boolAtPut(flag, &value, JVMFlag::ATTACH_ON_DEMAND);
 }
 
 // Enable only the "fine grained" flags. Do *not* touch
--- a/src/hotspot/share/services/management.cpp	Mon Aug 26 09:13:38 2019 +0200
+++ b/src/hotspot/share/services/management.cpp	Mon Aug 26 09:15:43 2019 +0200
@@ -1546,7 +1546,7 @@
 
       Handle sh(THREAD, s);
       char* str = java_lang_String::as_utf8_string(s);
-      JVMFlag* flag = JVMFlag::find_flag(str, strlen(str));
+      JVMFlag* flag = JVMFlag::find_flag(str);
       if (flag != NULL &&
           add_global_entry(env, sh, &globals[i], flag, THREAD)) {
         num_entries++;
--- a/src/hotspot/share/services/writeableFlags.cpp	Mon Aug 26 09:13:38 2019 +0200
+++ b/src/hotspot/share/services/writeableFlags.cpp	Mon Aug 26 09:15:43 2019 +0200
@@ -38,8 +38,8 @@
   strncat(buffer, src, TEMP_BUF_SIZE - 1 - strlen(buffer));
 }
 
-static void print_flag_error_message_bounds(const char* name, char* buffer) {
-  JVMFlagRange* range = JVMFlagRangeList::find(name);
+static void print_flag_error_message_bounds(const JVMFlag* flag, char* buffer) {
+  JVMFlagRange* range = JVMFlagRangeList::find(flag);
   if (range != NULL) {
     buffer_concat(buffer, "must have value in range ");
 
@@ -59,11 +59,12 @@
   }
 }
 
-static void print_flag_error_message_if_needed(JVMFlag::Error error, const char* name, FormatBuffer<80>& err_msg) {
+static void print_flag_error_message_if_needed(JVMFlag::Error error, const JVMFlag* flag, FormatBuffer<80>& err_msg) {
   if (error == JVMFlag::SUCCESS) {
     return;
   }
 
+  const char* name = flag->_name;
   char buffer[TEMP_BUF_SIZE] = {'\0'};
   if ((error != JVMFlag::MISSING_NAME) && (name != NULL)) {
     buffer_concat(buffer, name);
@@ -79,7 +80,7 @@
     case JVMFlag::NON_WRITABLE:
       buffer_concat(buffer, "flag is not writeable."); break;
     case JVMFlag::OUT_OF_BOUNDS:
-      if (name != NULL) { print_flag_error_message_bounds(name, buffer); } break;
+      if (name != NULL) { print_flag_error_message_bounds(flag, buffer); } break;
     case JVMFlag::VIOLATES_CONSTRAINT:
       buffer_concat(buffer, "value violates its flag's constraint."); break;
     case JVMFlag::INVALID_FLAG:
@@ -107,8 +108,9 @@
 }
 
 JVMFlag::Error WriteableFlags::set_bool_flag(const char* name, bool value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
-  JVMFlag::Error err = JVMFlag::boolAtPut(name, &value, origin);
-  print_flag_error_message_if_needed(err, name, err_msg);
+  JVMFlag* flag = JVMFlag::find_flag(name);
+  JVMFlag::Error err = JVMFlag::boolAtPut(flag, &value, origin);
+  print_flag_error_message_if_needed(err, flag, err_msg);
   return err;
 }
 
@@ -124,8 +126,9 @@
 }
 
 JVMFlag::Error WriteableFlags::set_int_flag(const char* name, int value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
-  JVMFlag::Error err = JVMFlag::intAtPut(name, &value, origin);
-  print_flag_error_message_if_needed(err, name, err_msg);
+  JVMFlag* flag = JVMFlag::find_flag(name);
+  JVMFlag::Error err = JVMFlag::intAtPut(flag, &value, origin);
+  print_flag_error_message_if_needed(err, flag, err_msg);
   return err;
 }
 
@@ -141,8 +144,9 @@
 }
 
 JVMFlag::Error WriteableFlags::set_uint_flag(const char* name, uint value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
-  JVMFlag::Error err = JVMFlag::uintAtPut(name, &value, origin);
-  print_flag_error_message_if_needed(err, name, err_msg);
+  JVMFlag* flag = JVMFlag::find_flag(name);
+  JVMFlag::Error err = JVMFlag::uintAtPut(flag, &value, origin);
+  print_flag_error_message_if_needed(err, flag, err_msg);
   return err;
 }
 
@@ -158,8 +162,9 @@
 }
 
 JVMFlag::Error WriteableFlags::set_intx_flag(const char* name, intx value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
-  JVMFlag::Error err = JVMFlag::intxAtPut(name, &value, origin);
-  print_flag_error_message_if_needed(err, name, err_msg);
+  JVMFlag* flag = JVMFlag::find_flag(name);
+  JVMFlag::Error err = JVMFlag::intxAtPut(flag, &value, origin);
+  print_flag_error_message_if_needed(err, flag, err_msg);
   return err;
 }
 
@@ -175,8 +180,9 @@
 }
 
 JVMFlag::Error WriteableFlags::set_uintx_flag(const char* name, uintx value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
-  JVMFlag::Error err = JVMFlag::uintxAtPut(name, &value, origin);
-  print_flag_error_message_if_needed(err, name, err_msg);
+  JVMFlag* flag = JVMFlag::find_flag(name);
+  JVMFlag::Error err = JVMFlag::uintxAtPut(flag, &value, origin);
+  print_flag_error_message_if_needed(err, flag, err_msg);
   return err;
 }
 
@@ -192,8 +198,9 @@
 }
 
 JVMFlag::Error WriteableFlags::set_uint64_t_flag(const char* name, uint64_t value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
-  JVMFlag::Error err = JVMFlag::uint64_tAtPut(name, &value, origin);
-  print_flag_error_message_if_needed(err, name, err_msg);
+  JVMFlag* flag = JVMFlag::find_flag(name);
+  JVMFlag::Error err = JVMFlag::uint64_tAtPut(flag, &value, origin);
+  print_flag_error_message_if_needed(err, flag, err_msg);
   return err;
 }
 
@@ -209,8 +216,9 @@
 }
 
 JVMFlag::Error WriteableFlags::set_size_t_flag(const char* name, size_t value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
-  JVMFlag::Error err = JVMFlag::size_tAtPut(name, &value, origin);
-  print_flag_error_message_if_needed(err, name, err_msg);
+  JVMFlag* flag = JVMFlag::find_flag(name);
+  JVMFlag::Error err = JVMFlag::size_tAtPut(flag, &value, origin);
+  print_flag_error_message_if_needed(err, flag, err_msg);
   return err;
 }
 
@@ -226,15 +234,17 @@
 }
 
 JVMFlag::Error WriteableFlags::set_double_flag(const char* name, double value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
-  JVMFlag::Error err = JVMFlag::doubleAtPut(name, &value, origin);
-  print_flag_error_message_if_needed(err, name, err_msg);
+  JVMFlag* flag = JVMFlag::find_flag(name);
+  JVMFlag::Error err = JVMFlag::doubleAtPut(flag, &value, origin);
+  print_flag_error_message_if_needed(err, flag, err_msg);
   return err;
 }
 
 // set a string global flag using value from AttachOperation
 JVMFlag::Error WriteableFlags::set_ccstr_flag(const char* name, const char* value, JVMFlag::Flags origin, FormatBuffer<80>& err_msg) {
-  JVMFlag::Error err = JVMFlag::ccstrAtPut((char*)name, &value, origin);
-  print_flag_error_message_if_needed(err, name, err_msg);
+  JVMFlag* flag = JVMFlag::find_flag(name);
+  JVMFlag::Error err = JVMFlag::ccstrAtPut(flag, &value, origin);
+  print_flag_error_message_if_needed(err, flag, err_msg);
   return err;
 }
 
@@ -267,7 +277,7 @@
     return JVMFlag::MISSING_VALUE;
   }
 
-  JVMFlag* f = JVMFlag::find_flag((char*)name, strlen(name));
+  JVMFlag* f = JVMFlag::find_flag(name);
   if (f) {
     // only writeable flags are allowed to be set
     if (f->is_writeable()) {