提交 ede513b5 编写于 作者: J jmelvin

7144328: Improper commandlines for -XX:+-UnlockCommercialFeatures require...

7144328: Improper commandlines for -XX:+-UnlockCommercialFeatures require proper warning/error messages
Summary: Provide custom error messages for locked commercial feature options which are not first unlocked.
Reviewed-by: dcubed, jcoomes, kamg
Contributed-by: james.melvin@oracle.com
上级 df550cbe
......@@ -816,8 +816,21 @@ bool Arguments::process_argument(const char* arg,
return true;
}
// 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) {
char locked_message_buf[BUFLEN];
locked_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);
} else {
jio_fprintf(defaultStream::error_stream(), "%s", locked_message_buf);
}
}
// allow for commandline "commenting out" options like -XX:#+Verbose
return arg[0] == '#';
}
......
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -81,6 +81,12 @@ bool Flag::is_unlocked() const {
}
}
// Get custom message for this locked flag, or return NULL if
// none is available.
void Flag::get_locked_message(char* buf, int buflen) const {
get_locked_message_ext(buf, buflen);
}
bool Flag::is_writeable() const {
return strcmp(kind, "{manageable}") == 0 ||
strcmp(kind, "{product rw}") == 0 ||
......@@ -260,17 +266,22 @@ inline bool str_equal(const char* s, char* q, size_t len) {
return strncmp(s, q, len) == 0;
}
Flag* Flag::find_flag(char* name, size_t length) {
for (Flag* current = &flagTable[0]; current->name; current++) {
// Search the flag table for a named flag
Flag* Flag::find_flag(char* name, size_t length, bool allow_locked) {
for (Flag* current = &flagTable[0]; current->name != NULL; current++) {
if (str_equal(current->name, name, length)) {
// Found a matching entry. Report locked flags only if allowed.
if (!(current->is_unlocked() || current->is_unlocker())) {
// disable use of diagnostic or experimental flags until they
// are explicitly unlocked
if (!allow_locked) {
// disable use of locked flags, e.g. diagnostic, experimental,
// commercial... until they are explicitly unlocked
return NULL;
}
}
return current;
}
}
// Flag name is not in the flag table
return NULL;
}
......
......@@ -222,7 +222,7 @@ struct Flag {
// number of flags
static size_t numFlags;
static Flag* find_flag(char* name, size_t length);
static Flag* find_flag(char* name, size_t length, bool allow_locked = false);
bool is_bool() const { return strcmp(type, "bool") == 0; }
bool get_bool() const { return *((bool*) addr); }
......@@ -259,6 +259,9 @@ struct Flag {
bool is_writeable_ext() const;
bool is_external_ext() const;
void get_locked_message(char*, int) const;
void get_locked_message_ext(char*, int) const;
void print_on(outputStream* st, bool withComments = false );
void print_as_flag(outputStream* st);
};
......
/*
* Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -61,4 +61,9 @@ inline bool Flag::is_external_ext() const {
return false;
}
inline void Flag::get_locked_message_ext(char* buf, int buflen) const {
assert(buf != NULL, "Buffer cannot be NULL");
buf[0] = '\0';
}
#endif // SHARE_VM_RUNTIME_GLOBALS_EXT_HPP
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册