提交 288fee2a 编写于 作者: H hseigel

8006298: Specifying malformed JFR options (-XX:+FlightRecorderOptions) outputs non-sensical error

Summary: Change error messages for malformed options so the messages are more useful.
Reviewed-by: mikael, kvn, nloodin
上级 a3031899
......@@ -827,7 +827,8 @@ bool Arguments::process_argument(const char* arg,
return true;
}
const char * const argname = *arg == '+' || *arg == '-' ? arg + 1 : arg;
bool has_plus_minus = (*arg == '+' || *arg == '-');
const char* const argname = has_plus_minus ? arg + 1 : arg;
if (is_newly_obsolete(arg, &since)) {
char version[256];
since.to_string(version, sizeof(version));
......@@ -838,13 +839,29 @@ bool Arguments::process_argument(const char* arg,
// For locked flags, report a custom error message if available.
// Otherwise, report the standard unrecognized VM option.
Flag* locked_flag = Flag::find_flag((char*)argname, strlen(argname), true);
if (locked_flag != NULL) {
size_t arg_len;
const char* equal_sign = strchr(argname, '=');
if (equal_sign == NULL) {
arg_len = strlen(argname);
} else {
arg_len = equal_sign - argname;
}
Flag* found_flag = Flag::find_flag((char*)argname, arg_len, true);
if (found_flag != NULL) {
char locked_message_buf[BUFLEN];
locked_flag->get_locked_message(locked_message_buf, BUFLEN);
found_flag->get_locked_message(locked_message_buf, BUFLEN);
if (strlen(locked_message_buf) == 0) {
jio_fprintf(defaultStream::error_stream(),
"Unrecognized VM option '%s'\n", argname);
if (found_flag->is_bool() && !has_plus_minus) {
jio_fprintf(defaultStream::error_stream(),
"Missing +/- setting for VM option '%s'\n", argname);
} else if (!found_flag->is_bool() && has_plus_minus) {
jio_fprintf(defaultStream::error_stream(),
"Unexpected +/- setting in VM option '%s'\n", argname);
} else {
jio_fprintf(defaultStream::error_stream(),
"Improperly specified VM option '%s'\n", argname);
}
} else {
jio_fprintf(defaultStream::error_stream(), "%s", locked_message_buf);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册