228 jio_snprintf(buffer, bufsz, "1." UINT32_FORMAT, spec_version);
229
230 PropertyList_add(&_system_properties,
231 new SystemProperty("java.vm.specification.vendor", spec_vendor, false));
232 PropertyList_add(&_system_properties,
233 new SystemProperty("java.vm.specification.version", buffer, false));
234 PropertyList_add(&_system_properties,
235 new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(), false));
236 }
237
238 /*
239 * -XX argument processing:
240 *
241 * -XX arguments are defined in several places, such as:
242 * globals.hpp, globals_<cpu>.hpp, globals_<os>.hpp, <compiler>_globals.hpp, or <gc>_globals.hpp.
243 * -XX arguments are parsed in parse_argument().
244 * -XX argument bounds checking is done in check_vm_args_consistency().
245 *
246 * Over time -XX arguments may change. There are mechanisms to handle common cases:
247 *
248 * ALIAS: An option may be renamed or replaced by another option. The old name can be supported by
249 * adding the old and new option names to the "aliased_jvm_flags" table. Delete the old
250 * variable from globals.hpp. This is often part of the process of deprecating a flag, but
251 * not all aliases need to be deprecated.
252 *
253 * DEPRECATED: An option may be supported, but a warning is printed to let the user know that support may
254 * be removed in the future. Both regular and aliased options may be deprecated.
255 * Add a deprecation warning for an option (or alias) by adding an entry in the
256 * "deprecated_jvm_flags" table. Specify the option name, the jdk version that deprecated the
257 * option, and the jdk version that will expire the option (use "undefined()" if removal has
258 * been not scheduled).
259 *
260 * OBSOLETE: An option may be removed (and deleted from globals.hpp), but still be accepted on the command
261 * line. A warning is printed to let the user know that support may be removed in the future.
262 * Add an obsolete warning for an option (or alias) by adding an entry in the
263 * "obsolete_jvm_flags" table. Specify the option name, the jdk version that obsoleted the option,
264 * and the jdk version that will expire the option (use "undefined()" if removal has been not
265 * scheduled).
266 *
267 * EXPIRED: When the current JDK version is equal or greater to the "accept_until" version of a deprecated
268 * or obsolete option, the system will flatly refuse to admit the existence of the flag. This
269 * allows a flag to die correctly over JDK releases.
270 * Note that manual cleanup of expired options should be done at major JDK version upgrades:
271 * - Expired options can be removed from the obsolete_jvm_flags, deprecated_jvm_flags tables,
272 * and aliased_jvm_flags tables.
273 * - Removed options may have global variable definitions that should also be
274 * removed (in globals.hpp, etc).
275 *
276 * Tests: Aliases are tested in VMAliasOptions.java.
277 * Deprecated options are tested in VMDeprecatedOptions.java.
278 * Obsolete options are tested in various files.
279 */
280
281 // Obsolete or deprecated -XX flag.
282 typedef struct {
283 const char* name;
284 JDK_Version obsoleted_in; // When the warning started (obsolete or deprecated).
285 JDK_Version accept_until; // Which version to start denying the existence of the flag (if scheduled).
286 } SpecialFlag;
287
288 // When a flag is eliminated, it can be added to this list in order to
289 // continue accepting this flag on the command-line, while issuing a warning
290 // and ignoring the value. Once the JDK version reaches the 'accept_until'
291 // limit, we flatly refuse to admit the existence of the flag.
292 static SpecialFlag const obsolete_jvm_flags[] = {
293 { "UseOldInlining", JDK_Version::jdk(9), JDK_Version::jdk(10) },
294 { "SafepointPollOffset", JDK_Version::jdk(9), JDK_Version::jdk(10) },
295 { "UseBoundThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) },
296 { "DefaultThreadPriority", JDK_Version::jdk(9), JDK_Version::jdk(10) },
297 { "NoYieldsInMicrolock", JDK_Version::jdk(9), JDK_Version::jdk(10) },
298 { "BackEdgeThreshold", JDK_Version::jdk(9), JDK_Version::jdk(10) },
299 { "UseNewReflection", JDK_Version::jdk(9), JDK_Version::jdk(10) },
300 { "ReflectionWrapResolutionErrors",JDK_Version::jdk(9), JDK_Version::jdk(10) },
301 { "VerifyReflectionBytecodes", JDK_Version::jdk(9), JDK_Version::jdk(10) },
302 { "AutoShutdownNMT", JDK_Version::jdk(9), JDK_Version::jdk(10) },
303 { "NmethodSweepFraction", JDK_Version::jdk(9), JDK_Version::jdk(10) },
304 { "NmethodSweepCheckInterval", JDK_Version::jdk(9), JDK_Version::jdk(10) },
305 { "CodeCacheMinimumFreeSpace", JDK_Version::jdk(9), JDK_Version::jdk(10) },
306 #ifndef ZERO
307 { "UseFastAccessorMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) },
308 { "UseFastEmptyMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) },
309 #endif // ZERO
310 { "UseCompilerSafepoints", JDK_Version::jdk(9), JDK_Version::jdk(10) },
311 { "AdaptiveSizePausePolicy", JDK_Version::jdk(9), JDK_Version::jdk(10) },
312 { "ParallelGCRetainPLAB", JDK_Version::jdk(9), JDK_Version::jdk(10) },
313 { "ThreadSafetyMargin", JDK_Version::jdk(9), JDK_Version::jdk(10) },
314 { "LazyBootClassLoader", JDK_Version::jdk(9), JDK_Version::jdk(10) },
315 { "StarvationMonitorInterval", JDK_Version::jdk(9), JDK_Version::jdk(10) },
316 { "PreInflateSpin", JDK_Version::jdk(9), JDK_Version::jdk(10) },
317 { NULL, JDK_Version(0), JDK_Version(0) }
318 };
319
320 // When a flag is deprecated, it can be added to this list in order to issuing a warning when the flag is used.
321 // Once the JDK version reaches the 'accept_until' limit, we flatly refuse to admit the existence of the flag.
322 static SpecialFlag const deprecated_jvm_flags[] = {
323 // deprecated non-alias flags:
324 { "MaxGCMinorPauseMillis", JDK_Version::jdk(8), JDK_Version::undefined() },
325 { "UseParNewGC", JDK_Version::jdk(9), JDK_Version::jdk(10) },
326
327 // deprecated alias flags (see also aliased_jvm_flags):
328 { "DefaultMaxRAMFraction", JDK_Version::jdk(8), JDK_Version::undefined() },
329 { "CMSMarkStackSizeMax", JDK_Version::jdk(9), JDK_Version::jdk(10) },
330 { "CMSMarkStackSize", JDK_Version::jdk(9), JDK_Version::jdk(10) },
331 { "G1MarkStackSize", JDK_Version::jdk(9), JDK_Version::jdk(10) },
332 { "ParallelMarkingThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) },
333 { "ParallelCMSThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) },
334 { "CreateMinidumpOnCrash", JDK_Version::jdk(9), JDK_Version::undefined() },
335 { NULL, JDK_Version(0), JDK_Version(0) }
336 };
337
338 // Flags that are aliases for other flags.
339 typedef struct {
340 const char* alias_name;
341 const char* real_name;
348 { "G1MarkStackSize", "MarkStackSize" },
349 { "ParallelMarkingThreads", "ConcGCThreads" },
350 { "ParallelCMSThreads", "ConcGCThreads" },
351 { "CreateMinidumpOnCrash", "CreateCoredumpOnCrash" },
352 { NULL, NULL}
353 };
354
355 // Returns 1 if the flag is special and jdk version is in the range specified.
356 // In this case the 'version' buffer is filled in with the version number when
357 // the flag became special.
358 // Returns -1 if the flag is special and has expired (should be ignored).
359 // Returns 0 if the flag is not special.
360 // Flag "flag_name" is a flag name stripped of '+', '-', and '='.
361 static int is_special_flag(const SpecialFlag special_table[], const char *flag_name, JDK_Version* version) {
362 assert(version != NULL, "Must provide a version buffer");
363 for (size_t i = 0; special_table[i].name != NULL; i++) {
364 const SpecialFlag& flag_status = special_table[i];
365 if ((strcmp(flag_status.name, flag_name) == 0)) {
366 if (flag_status.accept_until.is_undefined() ||
367 JDK_Version::current().compare(flag_status.accept_until) == -1) {
368 *version = flag_status.obsoleted_in;
369 return 1;
370 } else {
371 return -1;
372 }
373 }
374 }
375 return 0;
376 }
377
378 bool Arguments::is_newly_obsolete(const char *flag_name, JDK_Version* version) {
379 return (is_special_flag(obsolete_jvm_flags, flag_name, version) == 1);
380 }
381
382 int Arguments::is_deprecated_flag(const char *flag_name, JDK_Version* version) {
383 return is_special_flag(deprecated_jvm_flags, flag_name, version);
384 }
385
386 const char* Arguments::real_flag_name(const char *flag_name) {
387 for (size_t i = 0; aliased_jvm_flags[i].alias_name != NULL; i++) {
388 const AliasedFlag& flag_status = aliased_jvm_flags[i];
389 if (strcmp(flag_status.alias_name, flag_name) == 0) {
390 return flag_status.real_name;
391 }
392 }
393 return flag_name;
394 }
395
396 // Constructs the system class path (aka boot class path) from the following
397 // components, in order:
398 //
788 return real_name;
789 }
790 }
791 ShouldNotReachHere();
792 return NULL;
793 }
794
795 bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
796
797 // range of acceptable characters spelled out for portability reasons
798 #define NAME_RANGE "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]"
799 #define BUFLEN 255
800 char name[BUFLEN+1];
801 char dummy;
802 const char* real_name;
803 bool warn_if_deprecated = true;
804
805 if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
806 real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
807 if (real_name == NULL) {
808 return false; // "name" is a deprecated option that has expired.
809 }
810 return set_bool_flag(real_name, false, origin);
811 }
812 if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
813 real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
814 if (real_name == NULL) {
815 return false;
816 }
817 return set_bool_flag(real_name, true, origin);
818 }
819
820 char punct;
821 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') {
822 const char* value = strchr(arg, '=') + 1;
823 Flag* flag;
824
825 // this scanf pattern matches both strings (handled here) and numbers (handled later))
826 real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
827 if (real_name == NULL) {
828 return false;
995
996 // Determine if the flag has '+', '-', or '=' characters.
997 bool has_plus_minus = (*arg == '+' || *arg == '-');
998 const char* const argname = has_plus_minus ? arg + 1 : arg;
999
1000 size_t arg_len;
1001 const char* equal_sign = strchr(argname, '=');
1002 if (equal_sign == NULL) {
1003 arg_len = strlen(argname);
1004 } else {
1005 arg_len = equal_sign - argname;
1006 }
1007
1008 // Only make the obsolete check for valid arguments.
1009 if (arg_len <= BUFLEN) {
1010 // Construct a string which consists only of the argument name without '+', '-', or '='.
1011 char stripped_argname[BUFLEN+1];
1012 strncpy(stripped_argname, argname, arg_len);
1013 stripped_argname[arg_len] = '\0'; // strncpy may not null terminate.
1014
1015 if (is_newly_obsolete(stripped_argname, &since)) {
1016 char version[256];
1017 since.to_string(version, sizeof(version));
1018 warning("Ignoring option %s; support was removed in %s", stripped_argname, version);
1019 return true;
1020 }
1021 }
1022
1023 // For locked flags, report a custom error message if available.
1024 // Otherwise, report the standard unrecognized VM option.
1025 Flag* found_flag = Flag::find_flag((const char*)argname, arg_len, true, true);
1026 if (found_flag != NULL) {
1027 char locked_message_buf[BUFLEN];
1028 found_flag->get_locked_message(locked_message_buf, BUFLEN);
1029 if (strlen(locked_message_buf) == 0) {
1030 if (found_flag->is_bool() && !has_plus_minus) {
1031 jio_fprintf(defaultStream::error_stream(),
1032 "Missing +/- setting for VM option '%s'\n", argname);
1033 } else if (!found_flag->is_bool() && has_plus_minus) {
1034 jio_fprintf(defaultStream::error_stream(),
1035 "Unexpected +/- setting in VM option '%s'\n", argname);
|
228 jio_snprintf(buffer, bufsz, "1." UINT32_FORMAT, spec_version);
229
230 PropertyList_add(&_system_properties,
231 new SystemProperty("java.vm.specification.vendor", spec_vendor, false));
232 PropertyList_add(&_system_properties,
233 new SystemProperty("java.vm.specification.version", buffer, false));
234 PropertyList_add(&_system_properties,
235 new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(), false));
236 }
237
238 /*
239 * -XX argument processing:
240 *
241 * -XX arguments are defined in several places, such as:
242 * globals.hpp, globals_<cpu>.hpp, globals_<os>.hpp, <compiler>_globals.hpp, or <gc>_globals.hpp.
243 * -XX arguments are parsed in parse_argument().
244 * -XX argument bounds checking is done in check_vm_args_consistency().
245 *
246 * Over time -XX arguments may change. There are mechanisms to handle common cases:
247 *
248 * ALIASED: An option that is simply another name for another option. This is often
249 * part of the process of deprecating a flag, but not all aliases need
250 * to be deprecated.
251 *
252 * Create an alias for an option by adding the old and new option names to the
253 * "aliased_jvm_flags" table. Delete the old variable from globals.hpp (etc),.
254 *
255 * DEPRECATED: An option that is supported, but a warning is printed to let the user know that
256 * support may be removed in the future. Both regular and aliased options may be
257 * deprecated.
258 *
259 * Add a deprecation warning for an option (or alias) by adding an entry in the
260 * "deprecated_jvm_flags" table. Often an option "deprecated" in one major release will
261 * be made "obsolete" in the next. In this case the entry should be removed from the
262 * "deprecated_jvm_flags" table and added to the "obsolete_jvm_flags" table (see below).
263 *
264 * OBSOLETE: An option that has been removed (and deleted from globals.hpp), but is still accepted
265 * on the command line. A warning is printed to let the user know that option might not
266 * be accepted in the future.
267 *
268 * Add an obsolete warning for an option by adding an entry in the "obsolete_jvm_flags"
269 * table.
270 *
271 * EXPIRED: A deprecated or obsolete option that has an "accept_until" version less than or equal
272 * to the current JDK version. The system will flatly refuse to admit the existence of
273 * the flag. This allows a flag to die automatically over JDK releases.
274 *
275 * Note that manual cleanup of expired options should be done at major JDK version upgrades:
276 * - Expired options should be removed from the obsolete_jvm_flags, deprecated_jvm_flags,
277 * and aliased_jvm_flags tables.
278 * - Expired deprecated options should have their global variable definitions removed
279 * (in globals.hpp, etc).
280 *
281 * Tests: Aliases should be tested in VMAliasOptions.java.
282 * Deprecated options should be tested in VMDeprecatedOptions.java.
283 */
284
285 // Obsolete or deprecated -XX flag.
286 typedef struct {
287 const char* name;
288 JDK_Version warning_started_in; // When the warning started (obsolete or deprecated).
289 JDK_Version accept_until; // Which version to start denying the existence of the flag (if scheduled).
290 } SpecialFlag;
291
292 // When a flag is made obsolete, it can be added to this list in order to
293 // continue accepting this flag on the command-line, while issuing a warning
294 // and ignoring the value. Once the JDK version reaches the 'accept_until'
295 // limit, we flatly refuse to admit the existence of the flag. The 'accept_until'
296 // field can be set to undefined() if the expiration date has not yet been set.
297 // This table should be scrubbed of expired options on major JDK releases.
298 static SpecialFlag const obsolete_jvm_flags[] = {
299 { "UseOldInlining", JDK_Version::jdk(9), JDK_Version::jdk(10) },
300 { "SafepointPollOffset", JDK_Version::jdk(9), JDK_Version::jdk(10) },
301 { "UseBoundThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) },
302 { "DefaultThreadPriority", JDK_Version::jdk(9), JDK_Version::jdk(10) },
303 { "NoYieldsInMicrolock", JDK_Version::jdk(9), JDK_Version::jdk(10) },
304 { "BackEdgeThreshold", JDK_Version::jdk(9), JDK_Version::jdk(10) },
305 { "UseNewReflection", JDK_Version::jdk(9), JDK_Version::jdk(10) },
306 { "ReflectionWrapResolutionErrors",JDK_Version::jdk(9), JDK_Version::jdk(10) },
307 { "VerifyReflectionBytecodes", JDK_Version::jdk(9), JDK_Version::jdk(10) },
308 { "AutoShutdownNMT", JDK_Version::jdk(9), JDK_Version::jdk(10) },
309 { "NmethodSweepFraction", JDK_Version::jdk(9), JDK_Version::jdk(10) },
310 { "NmethodSweepCheckInterval", JDK_Version::jdk(9), JDK_Version::jdk(10) },
311 { "CodeCacheMinimumFreeSpace", JDK_Version::jdk(9), JDK_Version::jdk(10) },
312 #ifndef ZERO
313 { "UseFastAccessorMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) },
314 { "UseFastEmptyMethods", JDK_Version::jdk(9), JDK_Version::jdk(10) },
315 #endif // ZERO
316 { "UseCompilerSafepoints", JDK_Version::jdk(9), JDK_Version::jdk(10) },
317 { "AdaptiveSizePausePolicy", JDK_Version::jdk(9), JDK_Version::jdk(10) },
318 { "ParallelGCRetainPLAB", JDK_Version::jdk(9), JDK_Version::jdk(10) },
319 { "ThreadSafetyMargin", JDK_Version::jdk(9), JDK_Version::jdk(10) },
320 { "LazyBootClassLoader", JDK_Version::jdk(9), JDK_Version::jdk(10) },
321 { "StarvationMonitorInterval", JDK_Version::jdk(9), JDK_Version::jdk(10) },
322 { "PreInflateSpin", JDK_Version::jdk(9), JDK_Version::jdk(10) },
323 { NULL, JDK_Version(0), JDK_Version(0) }
324 };
325
326 // When a flag is deprecated, it can be added to this list in order to issue a warning when the flag is used.
327 // Once the JDK version reaches the 'accept_until' limit, we flatly refuse to admit the existence of the flag.
328 // The 'accept_until' field can be set to undefined() if the expiration date has not yet been set.
329 // If a deprecated option should be treated as obsolete before it is expired, it needs to be removed
330 // from this table and added to the obsolete_jvm_flags table.
331 // This table should be scrubbed of expired options on major JDK releases.
332 static SpecialFlag const deprecated_jvm_flags[] = {
333 // deprecated non-alias flags:
334 { "MaxGCMinorPauseMillis", JDK_Version::jdk(8), JDK_Version::undefined() },
335 { "UseParNewGC", JDK_Version::jdk(9), JDK_Version::jdk(10) },
336
337 // deprecated alias flags (see also aliased_jvm_flags):
338 { "DefaultMaxRAMFraction", JDK_Version::jdk(8), JDK_Version::undefined() },
339 { "CMSMarkStackSizeMax", JDK_Version::jdk(9), JDK_Version::jdk(10) },
340 { "CMSMarkStackSize", JDK_Version::jdk(9), JDK_Version::jdk(10) },
341 { "G1MarkStackSize", JDK_Version::jdk(9), JDK_Version::jdk(10) },
342 { "ParallelMarkingThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) },
343 { "ParallelCMSThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) },
344 { "CreateMinidumpOnCrash", JDK_Version::jdk(9), JDK_Version::undefined() },
345 { NULL, JDK_Version(0), JDK_Version(0) }
346 };
347
348 // Flags that are aliases for other flags.
349 typedef struct {
350 const char* alias_name;
351 const char* real_name;
358 { "G1MarkStackSize", "MarkStackSize" },
359 { "ParallelMarkingThreads", "ConcGCThreads" },
360 { "ParallelCMSThreads", "ConcGCThreads" },
361 { "CreateMinidumpOnCrash", "CreateCoredumpOnCrash" },
362 { NULL, NULL}
363 };
364
365 // Returns 1 if the flag is special and jdk version is in the range specified.
366 // In this case the 'version' buffer is filled in with the version number when
367 // the flag became special.
368 // Returns -1 if the flag is special and has expired (should be ignored).
369 // Returns 0 if the flag is not special.
370 // Flag "flag_name" is a flag name stripped of '+', '-', and '='.
371 static int is_special_flag(const SpecialFlag special_table[], const char *flag_name, JDK_Version* version) {
372 assert(version != NULL, "Must provide a version buffer");
373 for (size_t i = 0; special_table[i].name != NULL; i++) {
374 const SpecialFlag& flag_status = special_table[i];
375 if ((strcmp(flag_status.name, flag_name) == 0)) {
376 if (flag_status.accept_until.is_undefined() ||
377 JDK_Version::current().compare(flag_status.accept_until) == -1) {
378 *version = flag_status.warning_started_in;
379 return 1;
380 } else {
381 return -1;
382 }
383 }
384 }
385 return 0;
386 }
387
388 bool Arguments::is_obsolete_flag(const char *flag_name, JDK_Version* version) {
389 return (is_special_flag(obsolete_jvm_flags, flag_name, version) == 1);
390 }
391
392 int Arguments::is_deprecated_flag(const char *flag_name, JDK_Version* version) {
393 return is_special_flag(deprecated_jvm_flags, flag_name, version);
394 }
395
396 const char* Arguments::real_flag_name(const char *flag_name) {
397 for (size_t i = 0; aliased_jvm_flags[i].alias_name != NULL; i++) {
398 const AliasedFlag& flag_status = aliased_jvm_flags[i];
399 if (strcmp(flag_status.alias_name, flag_name) == 0) {
400 return flag_status.real_name;
401 }
402 }
403 return flag_name;
404 }
405
406 // Constructs the system class path (aka boot class path) from the following
407 // components, in order:
408 //
798 return real_name;
799 }
800 }
801 ShouldNotReachHere();
802 return NULL;
803 }
804
805 bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
806
807 // range of acceptable characters spelled out for portability reasons
808 #define NAME_RANGE "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]"
809 #define BUFLEN 255
810 char name[BUFLEN+1];
811 char dummy;
812 const char* real_name;
813 bool warn_if_deprecated = true;
814
815 if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
816 real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
817 if (real_name == NULL) {
818 return false;
819 }
820 return set_bool_flag(real_name, false, origin);
821 }
822 if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
823 real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
824 if (real_name == NULL) {
825 return false;
826 }
827 return set_bool_flag(real_name, true, origin);
828 }
829
830 char punct;
831 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') {
832 const char* value = strchr(arg, '=') + 1;
833 Flag* flag;
834
835 // this scanf pattern matches both strings (handled here) and numbers (handled later))
836 real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
837 if (real_name == NULL) {
838 return false;
1005
1006 // Determine if the flag has '+', '-', or '=' characters.
1007 bool has_plus_minus = (*arg == '+' || *arg == '-');
1008 const char* const argname = has_plus_minus ? arg + 1 : arg;
1009
1010 size_t arg_len;
1011 const char* equal_sign = strchr(argname, '=');
1012 if (equal_sign == NULL) {
1013 arg_len = strlen(argname);
1014 } else {
1015 arg_len = equal_sign - argname;
1016 }
1017
1018 // Only make the obsolete check for valid arguments.
1019 if (arg_len <= BUFLEN) {
1020 // Construct a string which consists only of the argument name without '+', '-', or '='.
1021 char stripped_argname[BUFLEN+1];
1022 strncpy(stripped_argname, argname, arg_len);
1023 stripped_argname[arg_len] = '\0'; // strncpy may not null terminate.
1024
1025 if (is_obsolete_flag(stripped_argname, &since)) {
1026 char version[256];
1027 since.to_string(version, sizeof(version));
1028 warning("Ignoring option %s; support was removed in %s", stripped_argname, version);
1029 return true;
1030 }
1031 }
1032
1033 // For locked flags, report a custom error message if available.
1034 // Otherwise, report the standard unrecognized VM option.
1035 Flag* found_flag = Flag::find_flag((const char*)argname, arg_len, true, true);
1036 if (found_flag != NULL) {
1037 char locked_message_buf[BUFLEN];
1038 found_flag->get_locked_message(locked_message_buf, BUFLEN);
1039 if (strlen(locked_message_buf) == 0) {
1040 if (found_flag->is_bool() && !has_plus_minus) {
1041 jio_fprintf(defaultStream::error_stream(),
1042 "Missing +/- setting for VM option '%s'\n", argname);
1043 } else if (!found_flag->is_bool() && has_plus_minus) {
1044 jio_fprintf(defaultStream::error_stream(),
1045 "Unexpected +/- setting in VM option '%s'\n", argname);
|