288 return strcmp(_name, "UnlockDiagnosticVMOptions") == 0 || 289 strcmp(_name, "UnlockExperimentalVMOptions") == 0 || 290 is_unlocker_ext(); 291 } 292 293 bool Flag::is_unlocked() const { 294 if (is_diagnostic()) { 295 return UnlockDiagnosticVMOptions; 296 } 297 if (is_experimental()) { 298 return UnlockExperimentalVMOptions; 299 } 300 return is_unlocked_ext(); 301 } 302 303 void Flag::unlock_diagnostic() { 304 assert(is_diagnostic(), "sanity"); 305 _flags = Flags(_flags & ~KIND_DIAGNOSTIC); 306 } 307 308 // Get custom message for this locked flag, or return NULL if 309 // none is available. 310 void Flag::get_locked_message(char* buf, int buflen) const { 311 buf[0] = '\0'; 312 if (is_diagnostic() && !is_unlocked()) { 313 jio_snprintf(buf, buflen, 314 "Error: VM option '%s' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.\n" 315 "Error: The unlock option must precede '%s'.\n", 316 _name, _name); 317 return; 318 } 319 if (is_experimental() && !is_unlocked()) { 320 jio_snprintf(buf, buflen, 321 "Error: VM option '%s' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.\n" 322 "Error: The unlock option must precede '%s'.\n", 323 _name, _name); 324 return; 325 } 326 if (is_develop() && is_product_build()) { 327 jio_snprintf(buf, buflen, "Error: VM option '%s' is develop and is available only in debug version of VM.\n", 328 _name); 329 return; 330 } 331 if (is_notproduct() && is_product_build()) { 332 jio_snprintf(buf, buflen, "Error: VM option '%s' is notproduct and is available only in debug version of VM.\n", 333 _name); 334 return; 335 } 336 get_locked_message_ext(buf, buflen); 337 } 338 339 bool Flag::is_writeable() const { 340 return is_manageable() || (is_product() && is_read_write()) || is_writeable_ext(); 341 } 342 343 // All flags except "manageable" are assumed to be internal flags. 344 // Long term, we need to define a mechanism to specify which flags 345 // are external/stable and change this function accordingly. 346 bool Flag::is_external() const { 347 return is_manageable() || is_external_ext(); 348 } 349 350 351 // Length of format string (e.g. "%.1234s") for printing ccstr below 352 #define FORMAT_BUFFER_LEN 16 353 354 PRAGMA_FORMAT_NONLITERAL_IGNORED_EXTERNAL 355 void Flag::print_on(outputStream* st, bool withComments, bool printRanges) { 356 // Don't print notproduct and develop flags in a product build. | 288 return strcmp(_name, "UnlockDiagnosticVMOptions") == 0 || 289 strcmp(_name, "UnlockExperimentalVMOptions") == 0 || 290 is_unlocker_ext(); 291 } 292 293 bool Flag::is_unlocked() const { 294 if (is_diagnostic()) { 295 return UnlockDiagnosticVMOptions; 296 } 297 if (is_experimental()) { 298 return UnlockExperimentalVMOptions; 299 } 300 return is_unlocked_ext(); 301 } 302 303 void Flag::unlock_diagnostic() { 304 assert(is_diagnostic(), "sanity"); 305 _flags = Flags(_flags & ~KIND_DIAGNOSTIC); 306 } 307 308 // Get custom message for this locked flag, or NULL if 309 // none is available. Returns message type produced. 310 Flag::MsgType Flag::get_locked_message(char* buf, int buflen) const { 311 buf[0] = '\0'; 312 if (is_diagnostic() && !is_unlocked()) { 313 jio_snprintf(buf, buflen, 314 "Error: VM option '%s' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.\n" 315 "Error: The unlock option must precede '%s'.\n", 316 _name, _name); 317 return Flag::DIAGNOSTIC_FLAG_BUT_LOCKED; 318 } 319 if (is_experimental() && !is_unlocked()) { 320 jio_snprintf(buf, buflen, 321 "Error: VM option '%s' is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions.\n" 322 "Error: The unlock option must precede '%s'.\n", 323 _name, _name); 324 return Flag::EXPERIMENTAL_FLAG_BUT_LOCKED; 325 } 326 if (is_develop() && is_product_build()) { 327 jio_snprintf(buf, buflen, "Error: VM option '%s' is develop and is available only in debug version of VM.\n", 328 _name); 329 return Flag::DEVELOPER_FLAG_BUT_PRODUCT_BUILD; 330 } 331 if (is_notproduct() && is_product_build()) { 332 jio_snprintf(buf, buflen, "Error: VM option '%s' is notproduct and is available only in debug version of VM.\n", 333 _name); 334 return Flag::NOTPRODUCT_FLAG_BUT_PRODUCT_BUILD; 335 } 336 get_locked_message_ext(buf, buflen); 337 return Flag::NONE; 338 } 339 340 bool Flag::is_writeable() const { 341 return is_manageable() || (is_product() && is_read_write()) || is_writeable_ext(); 342 } 343 344 // All flags except "manageable" are assumed to be internal flags. 345 // Long term, we need to define a mechanism to specify which flags 346 // are external/stable and change this function accordingly. 347 bool Flag::is_external() const { 348 return is_manageable() || is_external_ext(); 349 } 350 351 352 // Length of format string (e.g. "%.1234s") for printing ccstr below 353 #define FORMAT_BUFFER_LEN 16 354 355 PRAGMA_FORMAT_NONLITERAL_IGNORED_EXTERNAL 356 void Flag::print_on(outputStream* st, bool withComments, bool printRanges) { 357 // Don't print notproduct and develop flags in a product build. |