hotspot/src/share/vm/runtime/globals.cpp
changeset 12157 439a7166bf0f
parent 11441 a89f443814cd
child 12598 1256ef9b648a
equal deleted inserted replaced
12156:fb31de03f649 12157:439a7166bf0f
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    77              strcmp(kind, "{C2 experimental}") == 0) {
    77              strcmp(kind, "{C2 experimental}") == 0) {
    78     return UnlockExperimentalVMOptions;
    78     return UnlockExperimentalVMOptions;
    79   } else {
    79   } else {
    80     return is_unlocked_ext();
    80     return is_unlocked_ext();
    81   }
    81   }
       
    82 }
       
    83 
       
    84 // Get custom message for this locked flag, or return NULL if
       
    85 // none is available.
       
    86 void Flag::get_locked_message(char* buf, int buflen) const {
       
    87   get_locked_message_ext(buf, buflen);
    82 }
    88 }
    83 
    89 
    84 bool Flag::is_writeable() const {
    90 bool Flag::is_writeable() const {
    85   return strcmp(kind, "{manageable}") == 0 ||
    91   return strcmp(kind, "{manageable}") == 0 ||
    86          strcmp(kind, "{product rw}") == 0 ||
    92          strcmp(kind, "{product rw}") == 0 ||
   258   // s is null terminated, q is not!
   264   // s is null terminated, q is not!
   259   if (strlen(s) != (unsigned int) len) return false;
   265   if (strlen(s) != (unsigned int) len) return false;
   260   return strncmp(s, q, len) == 0;
   266   return strncmp(s, q, len) == 0;
   261 }
   267 }
   262 
   268 
   263 Flag* Flag::find_flag(char* name, size_t length) {
   269 // Search the flag table for a named flag
   264   for (Flag* current = &flagTable[0]; current->name; current++) {
   270 Flag* Flag::find_flag(char* name, size_t length, bool allow_locked) {
       
   271   for (Flag* current = &flagTable[0]; current->name != NULL; current++) {
   265     if (str_equal(current->name, name, length)) {
   272     if (str_equal(current->name, name, length)) {
       
   273       // Found a matching entry.  Report locked flags only if allowed.
   266       if (!(current->is_unlocked() || current->is_unlocker())) {
   274       if (!(current->is_unlocked() || current->is_unlocker())) {
   267         // disable use of diagnostic or experimental flags until they
   275         if (!allow_locked) {
   268         // are explicitly unlocked
   276           // disable use of locked flags, e.g. diagnostic, experimental,
   269         return NULL;
   277           // commercial... until they are explicitly unlocked
       
   278           return NULL;
       
   279         }
   270       }
   280       }
   271       return current;
   281       return current;
   272     }
   282     }
   273   }
   283   }
       
   284   // Flag name is not in the flag table
   274   return NULL;
   285   return NULL;
   275 }
   286 }
   276 
   287 
   277 // Returns the address of the index'th element
   288 // Returns the address of the index'th element
   278 static Flag* address_of_flag(CommandLineFlagWithType flag) {
   289 static Flag* address_of_flag(CommandLineFlagWithType flag) {