comparison src/share/vm/runtime/globals.cpp @ 17667:cd7a42c7be06

8027314: Java should recognize Diagnostic options if -XX:+UnlockDiagnosticVMOptions is not specified and print an informative message Summary: clarifying the error messages associated with vm options of type diagnostic, experimental, develop, and notproduct Reviewed-by: kvn, twisti, ctornqvi
author ccheung
date Thu, 16 Jan 2014 10:51:16 -0800
parents 396564992823
children d6c97434b745
comparison
equal deleted inserted replaced
17666:a81bc2b2c4d3 17667:cd7a42c7be06
60 MATERIALIZE_NOTPRODUCT_FLAG) 60 MATERIALIZE_NOTPRODUCT_FLAG)
61 61
62 MATERIALIZE_FLAGS_EXT 62 MATERIALIZE_FLAGS_EXT
63 63
64 64
65 static bool is_product_build() {
66 #ifdef PRODUCT
67 return true;
68 #else
69 return false;
70 #endif
71 }
72
65 void Flag::check_writable() { 73 void Flag::check_writable() {
66 if (is_constant_in_binary()) { 74 if (is_constant_in_binary()) {
67 fatal(err_msg("flag is constant: %s", _name)); 75 fatal(err_msg("flag is constant: %s", _name));
68 } 76 }
69 } 77 }
233 } 241 }
234 242
235 // Get custom message for this locked flag, or return NULL if 243 // Get custom message for this locked flag, or return NULL if
236 // none is available. 244 // none is available.
237 void Flag::get_locked_message(char* buf, int buflen) const { 245 void Flag::get_locked_message(char* buf, int buflen) const {
246 buf[0] = '\0';
247 if (is_diagnostic() && !is_unlocked()) {
248 jio_snprintf(buf, buflen, "Error: VM option '%s' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.\n",
249 _name);
250 return;
251 }
252 if (is_experimental() && !is_unlocked()) {
253 jio_snprintf(buf, buflen, "Error: VM option '%s' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.\n",
254 _name);
255 return;
256 }
257 if (is_develop() && is_product_build()) {
258 jio_snprintf(buf, buflen, "Error: VM option '%s' is develop and is available only in debug version of VM.\n",
259 _name);
260 return;
261 }
262 if (is_notproduct() && is_product_build()) {
263 jio_snprintf(buf, buflen, "Error: VM option '%s' is notproduct and is available only in debug version of VM.\n",
264 _name);
265 return;
266 }
238 get_locked_message_ext(buf, buflen); 267 get_locked_message_ext(buf, buflen);
239 } 268 }
240 269
241 bool Flag::is_writeable() const { 270 bool Flag::is_writeable() const {
242 return is_manageable() || (is_product() && is_read_write()) || is_writeable_ext(); 271 return is_manageable() || (is_product() && is_read_write()) || is_writeable_ext();
462 if (strlen(s) != (unsigned int) len) return false; 491 if (strlen(s) != (unsigned int) len) return false;
463 return strncmp(s, q, len) == 0; 492 return strncmp(s, q, len) == 0;
464 } 493 }
465 494
466 // Search the flag table for a named flag 495 // Search the flag table for a named flag
467 Flag* Flag::find_flag(const char* name, size_t length, bool allow_locked) { 496 Flag* Flag::find_flag(const char* name, size_t length, bool allow_locked, bool return_flag) {
468 for (Flag* current = &flagTable[0]; current->_name != NULL; current++) { 497 for (Flag* current = &flagTable[0]; current->_name != NULL; current++) {
469 if (str_equal(current->_name, name, length)) { 498 if (str_equal(current->_name, name, length)) {
470 // Found a matching entry. 499 // Found a matching entry.
471 // Don't report notproduct and develop flags in product builds. 500 // Don't report notproduct and develop flags in product builds.
472 if (current->is_constant_in_binary()) { 501 if (current->is_constant_in_binary()) {
473 return NULL; 502 return (return_flag == true ? current : NULL);
474 } 503 }
475 // Report locked flags only if allowed. 504 // Report locked flags only if allowed.
476 if (!(current->is_unlocked() || current->is_unlocker())) { 505 if (!(current->is_unlocked() || current->is_unlocker())) {
477 if (!allow_locked) { 506 if (!allow_locked) {
478 // disable use of locked flags, e.g. diagnostic, experimental, 507 // disable use of locked flags, e.g. diagnostic, experimental,