< prev index next >

src/hotspot/share/runtime/flags/jvmFlagAccess.cpp

Print this page
@@ -308,10 +308,21 @@
  }
  
  JVMFlag::Error JVMFlagAccess::set_ccstr(JVMFlag* flag, ccstr* value, JVMFlagOrigin origin) {
    if (flag == nullptr) return JVMFlag::INVALID_FLAG;
    if (!flag->is_ccstr()) return JVMFlag::WRONG_FORMAT;
+   const JVMTypedFlagLimit<ccstr>* constraint = (const JVMTypedFlagLimit<ccstr>*)JVMFlagLimit::get_constraint(flag);
+   if (constraint != nullptr && constraint->phase() <= JVMFlagLimit::validating_phase()) {
+     bool verbose = JVMFlagLimit::verbose_checks_needed() | (origin == JVMFlagOrigin::ERGONOMIC);
+     JVMFlag::Error err = ((JVMFlagConstraintFunc_ccstr)constraint->constraint_func())(*value, verbose);
+     if (err != JVMFlag::SUCCESS) {
+       if (origin == JVMFlagOrigin::ERGONOMIC) {
+         fatal("FLAG_SET_ERGO cannot be used to set an invalid value for %s", flag->name());
+       }
+       return err;
+     }
+   }
    ccstr old_value = flag->get_ccstr();
    trace_flag_changed<ccstr, EventStringFlagChanged>(flag, old_value, *value, origin);
    char* new_value = nullptr;
    if (*value != nullptr) {
      new_value = os::strdup_check_oom(*value);
< prev index next >