hotspot/src/share/vm/runtime/globals.cpp
changeset 22518 e23c5545e376
parent 22194 e4bef4b8cdb4
child 22527 a5de5537d8a6
equal deleted inserted replaced
22517:8de4bcd74cd5 22518:e23c5545e376
    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,