aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmelvin <none@none>2012-03-20 16:46:39 -0400
committerjmelvin <none@none>2012-03-20 16:46:39 -0400
commita3d1975c3661ed4aae4b20952cd542c21d7d3878 (patch)
tree87d5103ff493261bdaa82edde0dc96051085c97e
parent0b9bd9dda539312405eceb696a22fb43f551c472 (diff)
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
-rw-r--r--src/share/vm/runtime/arguments.cpp17
-rw-r--r--src/share/vm/runtime/globals.cpp23
-rw-r--r--src/share/vm/runtime/globals.hpp5
-rw-r--r--src/share/vm/runtime/globals_ext.hpp7
4 files changed, 42 insertions, 10 deletions
diff --git a/src/share/vm/runtime/arguments.cpp b/src/share/vm/runtime/arguments.cpp
index 5740794db..decf89125 100644
--- a/src/share/vm/runtime/arguments.cpp
+++ b/src/share/vm/runtime/arguments.cpp
@@ -816,8 +816,21 @@ bool Arguments::process_argument(const char* arg,
return true;
}
- jio_fprintf(defaultStream::error_stream(),
- "Unrecognized VM option '%s'\n", argname);
+ // 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] == '#';
}
diff --git a/src/share/vm/runtime/globals.cpp b/src/share/vm/runtime/globals.cpp
index 13ce54fb4..02d105733 100644
--- a/src/share/vm/runtime/globals.cpp
+++ b/src/share/vm/runtime/globals.cpp
@@ -1,5 +1,5 @@
/*
- * 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
- return NULL;
+ 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;
}
diff --git a/src/share/vm/runtime/globals.hpp b/src/share/vm/runtime/globals.hpp
index 484442a7f..5476b7257 100644
--- a/src/share/vm/runtime/globals.hpp
+++ b/src/share/vm/runtime/globals.hpp
@@ -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);
};
diff --git a/src/share/vm/runtime/globals_ext.hpp b/src/share/vm/runtime/globals_ext.hpp
index 15191df60..7642fa9de 100644
--- a/src/share/vm/runtime/globals_ext.hpp
+++ b/src/share/vm/runtime/globals_ext.hpp
@@ -1,5 +1,5 @@
/*
- * 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