--- old/src/share/vm/runtime/globals.cpp 2015-07-31 12:40:19.000000000 -0500 +++ new/src/share/vm/runtime/globals.cpp 2015-07-31 12:40:19.000000000 -0500 @@ -515,6 +515,20 @@ } } +const char* Flag::flag_error_str(Flag::Error error) { + switch (error) { + case Flag::MISSING_NAME: return "MISSING_NAME"; + case Flag::MISSING_VALUE: return "MISSING_VALUE"; + case Flag::NON_WRITABLE: return "NON_WRITABLE"; + case Flag::OUT_OF_BOUNDS: return "OUT_OF_BOUNDS"; + case Flag::VIOLATES_CONSTRAINT: return "VIOLATES_CONSTRAINT"; + case Flag::INVALID_FLAG: return "INVALID_FLAG"; + case Flag::ERR_OTHER: return "ERR_OTHER"; + case Flag::SUCCESS: return "SUCCESS"; + default: return "NULL"; + } +} + // 4991491 do not "optimize out" the was_set false values: omitting them // tickles a Microsoft compiler bug causing flagTable to be malformed @@ -758,21 +772,11 @@ e.commit(); } -static Flag::Error get_status_error(Flag::Error status_range, Flag::Error status_constraint) { - if (status_range != Flag::SUCCESS) { - return status_range; - } else if (status_constraint != Flag::SUCCESS) { - return status_constraint; - } else { - return Flag::SUCCESS; - } -} - static Flag::Error apply_constraint_and_check_range_bool(const char* name, bool* new_value, bool verbose = true) { Flag::Error status = Flag::SUCCESS; CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); if (constraint != NULL) { - status = constraint->apply_bool(new_value, verbose); + status = constraint->apply_bool(*new_value, verbose); } return status; } @@ -811,17 +815,18 @@ } static Flag::Error apply_constraint_and_check_range_int(const char* name, int* new_value, bool verbose = true) { - Flag::Error range_status = Flag::SUCCESS; + Flag::Error status = Flag::SUCCESS; CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { - range_status = range->check_int(*new_value, verbose); + status = range->check_int(*new_value, verbose); } - Flag::Error constraint_status = Flag::SUCCESS; - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); - if (constraint != NULL) { - constraint_status = constraint->apply_int(new_value, verbose); + if (status == Flag::SUCCESS) { + CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); + if (constraint != NULL) { + status = constraint->apply_int(*new_value, verbose); + } } - return get_status_error(range_status, constraint_status); + return status; } Flag::Error CommandLineFlags::intAt(const char* name, size_t len, int* value, bool allow_locked, bool return_flag) { @@ -856,17 +861,18 @@ } static Flag::Error apply_constraint_and_check_range_uint(const char* name, uint* new_value, bool verbose = true) { - Flag::Error range_status = Flag::SUCCESS; + Flag::Error status = Flag::SUCCESS; CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { - range_status = range->check_uint(*new_value, verbose); + status = range->check_uint(*new_value, verbose); } - Flag::Error constraint_status = Flag::SUCCESS; - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); - if (constraint != NULL) { - constraint_status = constraint->apply_uint(new_value, verbose); + if (status == Flag::SUCCESS) { + CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); + if (constraint != NULL) { + status = constraint->apply_uint(*new_value, verbose); + } } - return get_status_error(range_status, constraint_status); + return status; } Flag::Error CommandLineFlags::uintAt(const char* name, size_t len, uint* value, bool allow_locked, bool return_flag) { @@ -909,17 +915,18 @@ } static Flag::Error apply_constraint_and_check_range_intx(const char* name, intx* new_value, bool verbose = true) { - Flag::Error range_status = Flag::SUCCESS; + Flag::Error status = Flag::SUCCESS; CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { - range_status = range->check_intx(*new_value, verbose); + status = range->check_intx(*new_value, verbose); } - Flag::Error constraint_status = Flag::SUCCESS; - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); - if (constraint != NULL) { - constraint_status = constraint->apply_intx(new_value, verbose); + if (status == Flag::SUCCESS) { + CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); + if (constraint != NULL) { + status = constraint->apply_intx(*new_value, verbose); + } } - return get_status_error(range_status, constraint_status); + return status; } Flag::Error CommandLineFlags::intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin) { @@ -956,17 +963,18 @@ } static Flag::Error apply_constraint_and_check_range_uintx(const char* name, uintx* new_value, bool verbose = true) { - Flag::Error range_status = Flag::SUCCESS; + Flag::Error status = Flag::SUCCESS; CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { - range_status = range->check_uintx(*new_value, verbose); + status = range->check_uintx(*new_value, verbose); } - Flag::Error constraint_status = Flag::SUCCESS; - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); - if (constraint != NULL) { - constraint_status = constraint->apply_uintx(new_value, verbose); + if (status == Flag::SUCCESS) { + CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); + if (constraint != NULL) { + status = constraint->apply_uintx(*new_value, verbose); + } } - return get_status_error(range_status, constraint_status); + return status; } Flag::Error CommandLineFlags::uintxAtPut(const char* name, size_t len, uintx* value, Flag::Flags origin) { @@ -1003,17 +1011,18 @@ } static Flag::Error apply_constraint_and_check_range_uint64_t(const char* name, uint64_t* new_value, bool verbose = true) { - Flag::Error range_status = Flag::SUCCESS; + Flag::Error status = Flag::SUCCESS; CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { - range_status = range->check_uint64_t(*new_value, verbose); + status = range->check_uint64_t(*new_value, verbose); } - Flag::Error constraint_status = Flag::SUCCESS; - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); - if (constraint != NULL) { - constraint_status = constraint->apply_uint64_t(new_value, verbose); + if (status == Flag::SUCCESS) { + CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); + if (constraint != NULL) { + status = constraint->apply_uint64_t(*new_value, verbose); + } } - return get_status_error(range_status, constraint_status); + return status; } Flag::Error CommandLineFlags::uint64_tAtPut(const char* name, size_t len, uint64_t* value, Flag::Flags origin) { @@ -1050,17 +1059,18 @@ } static Flag::Error apply_constraint_and_check_range_size_t(const char* name, size_t* new_value, bool verbose = true) { - Flag::Error range_status = Flag::SUCCESS; + Flag::Error status = Flag::SUCCESS; CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { - range_status = range->check_size_t(*new_value, verbose); + status = range->check_size_t(*new_value, verbose); } - Flag::Error constraint_status = Flag::SUCCESS; - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); - if (constraint != NULL) { - constraint_status = constraint->apply_size_t(new_value, verbose); + if (status == Flag::SUCCESS) { + CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); + if (constraint != NULL) { + status = constraint->apply_size_t(*new_value, verbose); + } } - return get_status_error(range_status, constraint_status); + return status; } Flag::Error CommandLineFlags::size_tAtPut(const char* name, size_t len, size_t* value, Flag::Flags origin) { @@ -1097,17 +1107,18 @@ } static Flag::Error apply_constraint_and_check_range_double(const char* name, double* new_value, bool verbose = true) { - Flag::Error range_status = Flag::SUCCESS; + Flag::Error status = Flag::SUCCESS; CommandLineFlagRange* range = CommandLineFlagRangeList::find(name); if (range != NULL) { - range_status = range->check_double(*new_value, verbose); + status = range->check_double(*new_value, verbose); } - Flag::Error constraint_status = Flag::SUCCESS; - CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); - if (constraint != NULL) { - constraint_status = constraint->apply_double(new_value, verbose); + if (status == Flag::SUCCESS) { + CommandLineFlagConstraint* constraint = CommandLineFlagConstraintList::find_if_needs_check(name); + if (constraint != NULL) { + status = constraint->apply_double(*new_value, verbose); + } } - return get_status_error(range_status, constraint_status); + return status; } Flag::Error CommandLineFlags::doubleAtPut(const char* name, size_t len, double* value, Flag::Flags origin) {