Mercurial > hg > truffle
comparison src/share/vm/runtime/globals.cpp @ 5947:80fe40862b02
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
author | jmelvin |
---|---|
date | Tue, 20 Mar 2012 16:46:39 -0400 |
parents | 4f25538b54c9 |
children | f47478089efc |
comparison
equal
deleted
inserted
replaced
5946:3d7ea1dbe0de | 5947:80fe40862b02 |
---|---|
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) { |