< prev index next >

src/share/vm/runtime/arguments.cpp

Print this page




 231       new SystemProperty("java.vm.specification.version", buffer, false));
 232   PropertyList_add(&_system_properties,
 233       new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(),  false));
 234 }
 235 
 236 /*
 237  *  -XX argument processing:
 238  * 
 239  *  -XX arguments are defined in several places, such as:
 240  *      globals.hpp, globals_<cpu>.hpp, globals_<os>.hpp, <compiler>_globals.hpp, or <gc>_globals.hpp.
 241  *  -XX arguments are parsed in parse_argument().
 242  *  -XX argument bounds checking is done in check_vm_args_consistency().
 243  * 
 244  * Over time -XX arguments may change. There are mechanisms to handle common cases:
 245  * 
 246  *      ALIASED: An option that is simply another name for another option. This is often
 247  *               part of the process of deprecating a flag, but not all aliases need
 248  *               to be deprecated.
 249  * 
 250  *               Create an alias for an option by adding the old and new option names to the 
 251  *               "aliased_jvm_flags" table. Delete the old variable from globals.hpp (etc),.
 252  * 
 253  *   DEPRECATED: An option that is supported, but a warning is printed to let the user know that
 254  *               support may be removed in the future. Both regular and aliased options may be
 255  *               deprecated.
 256  * 
 257  *               Add a deprecation warning for an option (or alias) by adding an entry in the 
 258  *               "deprecated_jvm_flags" table. Often an option "deprecated" in one major release will
 259  *               be made "obsolete" in the next. In this case the entry should be removed from the 
 260  *               "deprecated_jvm_flags" table and added to the "obsolete_jvm_flags" table (see below).

 261  *
 262  *     OBSOLETE: An option that has been removed (and deleted from globals.hpp), but is still accepted
 263  *               on the command line. A warning is printed to let the user know that option might not
 264  *               be accepted in the future.
 265  * 
 266  *               Add an obsolete warning for an option by adding an entry in the "obsolete_jvm_flags"
 267  *               table.
 268  * 
 269  *      EXPIRED: A deprecated or obsolete option that has an "accept_until" version less than or equal
 270  *               to the current JDK version. The system will flatly refuse to admit the existence of
 271  *               the flag. This allows a flag to die automatically over JDK releases. 
 272  * 
 273  *               Note that manual cleanup of expired options should be done at major JDK version upgrades:
 274  *                  - Expired options should be removed from the obsolete_jvm_flags, deprecated_jvm_flags,
 275  *                    and aliased_jvm_flags tables.
 276  *                  - Expired deprecated options should have their global variable definitions removed
 277  *                    (in globals.hpp, etc).













 278  * 
 279  * Tests:  Aliases should be tested in VMAliasOptions.java.
 280  *         Deprecated options should be tested in VMDeprecatedOptions.java. 
 281  */
 282 
 283 // Obsolete or deprecated -XX flag.
 284 typedef struct {
 285   const char* name;
 286   JDK_Version warning_started_in; // When the warning started (obsolete or deprecated).
 287   JDK_Version accept_until; // Which version to start denying the existence of the flag (if scheduled).

 288 } SpecialFlag;
 289 
 290 // When a flag is made obsolete, it can be added to this list in order to
 291 // continue accepting this flag on the command-line, while issuing a warning
 292 // and ignoring the value.  Once the JDK version reaches the 'accept_until'
 293 // limit, we flatly refuse to admit the existence of the flag. The 'accept_until'
 294 // field can be set to undefined() if the expiration date has not yet been set.
 295 // This table should be scrubbed of expired options on major JDK releases.
 296 static SpecialFlag const obsolete_jvm_flags[] = {
 297   { "UseOldInlining",                JDK_Version::jdk(9), JDK_Version::jdk(10) },
 298   { "SafepointPollOffset",           JDK_Version::jdk(9), JDK_Version::jdk(10) },
 299   { "UseBoundThreads",               JDK_Version::jdk(9), JDK_Version::jdk(10) },
 300   { "DefaultThreadPriority",         JDK_Version::jdk(9), JDK_Version::jdk(10) },
 301   { "NoYieldsInMicrolock",           JDK_Version::jdk(9), JDK_Version::jdk(10) },
 302   { "BackEdgeThreshold",             JDK_Version::jdk(9), JDK_Version::jdk(10) },
 303   { "UseNewReflection",              JDK_Version::jdk(9), JDK_Version::jdk(10) },
 304   { "ReflectionWrapResolutionErrors",JDK_Version::jdk(9), JDK_Version::jdk(10) },
 305   { "VerifyReflectionBytecodes",     JDK_Version::jdk(9), JDK_Version::jdk(10) },
 306   { "AutoShutdownNMT",               JDK_Version::jdk(9), JDK_Version::jdk(10) },
 307   { "NmethodSweepFraction",          JDK_Version::jdk(9), JDK_Version::jdk(10) },
 308   { "NmethodSweepCheckInterval",     JDK_Version::jdk(9), JDK_Version::jdk(10) },
 309   { "CodeCacheMinimumFreeSpace",     JDK_Version::jdk(9), JDK_Version::jdk(10) },




































 310 #ifndef ZERO
 311   { "UseFastAccessorMethods",        JDK_Version::jdk(9), JDK_Version::jdk(10) },
 312   { "UseFastEmptyMethods",           JDK_Version::jdk(9), JDK_Version::jdk(10) },
 313 #endif // ZERO
 314   { "UseCompilerSafepoints",         JDK_Version::jdk(9), JDK_Version::jdk(10) },
 315   { "AdaptiveSizePausePolicy",       JDK_Version::jdk(9), JDK_Version::jdk(10) },
 316   { "ParallelGCRetainPLAB",          JDK_Version::jdk(9), JDK_Version::jdk(10) },
 317   { "ThreadSafetyMargin",            JDK_Version::jdk(9), JDK_Version::jdk(10) },
 318   { "LazyBootClassLoader",           JDK_Version::jdk(9), JDK_Version::jdk(10) },
 319   { "StarvationMonitorInterval",     JDK_Version::jdk(9), JDK_Version::jdk(10) },
 320   { "PreInflateSpin",                JDK_Version::jdk(9), JDK_Version::jdk(10) },
 321   { NULL, JDK_Version(0), JDK_Version(0) }
 322 };
 323 
 324 // When a flag is deprecated, it can be added to this list in order to issue a warning when the flag is used.
 325 // Once the JDK version reaches the 'accept_until' limit, we flatly refuse to admit the existence of the flag.
 326 // The 'accept_until' field can be set to undefined() if the expiration date has not yet been set.
 327 // If a deprecated option should be treated as obsolete before it is expired, it needs to be removed
 328 // from this table and added to the obsolete_jvm_flags table.
 329 // This table should be scrubbed of expired options on major JDK releases.
 330 static SpecialFlag const deprecated_jvm_flags[] = {
 331   // deprecated non-alias flags:
 332   { "MaxGCMinorPauseMillis",        JDK_Version::jdk(8), JDK_Version::undefined() },
 333   { "UseParNewGC",                  JDK_Version::jdk(9), JDK_Version::jdk(10) },
 334   
 335   // deprecated alias flags (see also aliased_jvm_flags):
 336   { "DefaultMaxRAMFraction",        JDK_Version::jdk(8), JDK_Version::undefined() },
 337   { "CMSMarkStackSizeMax",          JDK_Version::jdk(9), JDK_Version::jdk(10) },
 338   { "CMSMarkStackSize",             JDK_Version::jdk(9), JDK_Version::jdk(10) },
 339   { "G1MarkStackSize",              JDK_Version::jdk(9), JDK_Version::jdk(10) },
 340   { "ParallelMarkingThreads",       JDK_Version::jdk(9), JDK_Version::jdk(10) },
 341   { "ParallelCMSThreads",           JDK_Version::jdk(9), JDK_Version::jdk(10) },
 342   { "CreateMinidumpOnCrash",        JDK_Version::jdk(9), JDK_Version::undefined() },
 343   { NULL, JDK_Version(0), JDK_Version(0) }
 344 };
 345 
 346 // Flags that are aliases for other flags.
 347 typedef struct {
 348   const char* alias_name;
 349   const char* real_name;
 350 } AliasedFlag;
 351 
 352 static AliasedFlag const aliased_jvm_flags[] = {
 353   { "DefaultMaxRAMFraction",    "MaxRAMFraction"    },
 354   { "CMSMarkStackSizeMax",      "MarkStackSizeMax"  },
 355   { "CMSMarkStackSize",         "MarkStackSize"     },
 356   { "G1MarkStackSize",          "MarkStackSize"     },
 357   { "ParallelMarkingThreads",   "ConcGCThreads"     },
 358   { "ParallelCMSThreads",       "ConcGCThreads"     },
 359   { "CreateMinidumpOnCrash",    "CreateCoredumpOnCrash" },
 360   { NULL, NULL}
 361 };
 362 
 363 // Returns 1 if the flag is special and jdk version is in the range specified.
 364 //     In this case the 'version' buffer is filled in with the version number when 
 365 //     the flag became special.
 366 // Returns -1 if the flag is special and has expired (should be ignored).
 367 // Returns 0 if the flag is not special.
 368 // Flag "flag_name" is a flag name stripped of '+', '-', and '='.
 369 static int is_special_flag(const SpecialFlag special_table[], const char *flag_name, JDK_Version* version) {
 370   assert(version != NULL, "Must provide a version buffer");
 371   for (size_t i = 0; special_table[i].name != NULL; i++) {
 372     const SpecialFlag& flag_status = special_table[i];
 373     if ((strcmp(flag_status.name, flag_name) == 0)) {
 374       if (flag_status.accept_until.is_undefined() ||
 375           JDK_Version::current().compare(flag_status.accept_until) == -1) {
 376         *version = flag_status.warning_started_in;
 377         return 1;
 378       } else {
 379         return -1;
 380       }







 381     }
 382   }
 383   return 0;
 384 }
 385 
 386 bool Arguments::is_obsolete_flag(const char *flag_name, JDK_Version* version) {
 387   return (is_special_flag(obsolete_jvm_flags, flag_name, version) == 1);










 388 }
 389 
 390 int Arguments::is_deprecated_flag(const char *flag_name, JDK_Version* version) {
 391   return is_special_flag(deprecated_jvm_flags, flag_name, version);













 392 }
 393 
 394 const char* Arguments::real_flag_name(const char *flag_name) {
 395   for (size_t i = 0; aliased_jvm_flags[i].alias_name != NULL; i++) {
 396     const AliasedFlag& flag_status = aliased_jvm_flags[i];
 397     if (strcmp(flag_status.alias_name, flag_name) == 0) {
 398         return flag_status.real_name;
 399     }
 400   }
 401   return flag_name;
 402 }
 403 


































































 404 // Constructs the system class path (aka boot class path) from the following
 405 // components, in order:
 406 //
 407 //     prefix           // from -Xbootclasspath/p:...
 408 //     base             // from os::get_system_properties() or -Xbootclasspath=
 409 //     suffix           // from -Xbootclasspath/a:...
 410 //
 411 // This could be AllStatic, but it isn't needed after argument processing is
 412 // complete.
 413 class SysClassPath: public StackObj {
 414 public:
 415   SysClassPath(const char* base);
 416   ~SysClassPath();
 417 
 418   inline void set_base(const char* base);
 419   inline void add_prefix(const char* prefix);
 420   inline void add_suffix_to_prefix(const char* suffix);
 421   inline void add_suffix(const char* suffix);
 422   inline void reset_path(const char* base);
 423 


 761     // each new setting adds another LINE to the switch:
 762     sprintf(buf, "%s\n%s", old_value, new_value);
 763     value = buf;
 764     free_this_too = buf;
 765   }
 766   (void) CommandLineFlags::ccstrAtPut(name, &value, origin);
 767   // CommandLineFlags always returns a pointer that needs freeing.
 768   FREE_C_HEAP_ARRAY(char, value);
 769   if (free_this_too != NULL) {
 770     // CommandLineFlags made its own copy, so I must delete my own temp. buffer.
 771     FREE_C_HEAP_ARRAY(char, free_this_too);
 772   }
 773   return true;
 774 }
 775 
 776 const char* Arguments::handle_aliases_and_deprecation(const char* arg, bool warn) {
 777   const char* real_name = real_flag_name(arg);
 778   JDK_Version since = JDK_Version();
 779   switch (is_deprecated_flag(arg, &since)) {
 780     case -1:
 781       return NULL;
 782     case 0:
 783       return real_name;
 784     case 1: {
 785       if (warn) {
 786         char version[256];
 787         since.to_string(version, sizeof(version));
 788         if (real_name != arg) {
 789           warning("Option %s was deprecated in version %s and will likely be removed in a future release. Use option %s instead.",
 790                   arg, version, real_name);
 791         } else {
 792           warning("Option %s was deprecated in version %s and will likely be removed in a future release.",
 793                   arg, version);
 794         }
 795       }
 796       return real_name;
 797     }
 798   }
 799   ShouldNotReachHere();
 800   return NULL;
 801 }


3730       vm_exit(0);
3731     }
3732 #endif
3733   }
3734   return JNI_OK;
3735 }
3736 
3737 static void print_options(const JavaVMInitArgs *args) {
3738   const char* tail;
3739   for (int index = 0; index < args->nOptions; index++) {
3740     const JavaVMOption *option = args->options + index;
3741     if (match_option(option, "-XX:", &tail)) {
3742       logOption(tail);
3743     }
3744   }
3745 }
3746 
3747 // Parse entry point called from JNI_CreateJavaVM
3748 
3749 jint Arguments::parse(const JavaVMInitArgs* args) {

3750 
3751   // Initialize ranges and constraints
3752   CommandLineFlagRangeList::init();
3753   CommandLineFlagConstraintList::init();
3754 
3755   // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed.
3756   const char* hotspotrc = ".hotspotrc";
3757   char* flags_file = NULL;
3758   bool settings_file_specified = false;
3759   bool needs_hotspotrc_warning = false;
3760   ScopedVMInitArgs java_tool_options_args;
3761   ScopedVMInitArgs java_options_args;
3762 
3763   jint code =
3764       parse_java_tool_options_environment_variable(&java_tool_options_args);
3765   if (code != JNI_OK) {
3766     return code;
3767   }
3768 
3769   code = parse_java_options_environment_variable(&java_options_args);




 231       new SystemProperty("java.vm.specification.version", buffer, false));
 232   PropertyList_add(&_system_properties,
 233       new SystemProperty("java.vm.vendor", VM_Version::vm_vendor(),  false));
 234 }
 235 
 236 /*
 237  *  -XX argument processing:
 238  *
 239  *  -XX arguments are defined in several places, such as:
 240  *      globals.hpp, globals_<cpu>.hpp, globals_<os>.hpp, <compiler>_globals.hpp, or <gc>_globals.hpp.
 241  *  -XX arguments are parsed in parse_argument().
 242  *  -XX argument bounds checking is done in check_vm_args_consistency().
 243  *
 244  * Over time -XX arguments may change. There are mechanisms to handle common cases:
 245  *
 246  *      ALIASED: An option that is simply another name for another option. This is often
 247  *               part of the process of deprecating a flag, but not all aliases need
 248  *               to be deprecated.
 249  *
 250  *               Create an alias for an option by adding the old and new option names to the
 251  *               "aliased_jvm_flags" table. Delete the old variable from globals.hpp (etc).
 252  *
 253  *   DEPRECATED: An option that is supported, but a warning is printed to let the user know that
 254  *               support may be removed in the future. Both regular and aliased options may be
 255  *               deprecated.
 256  *
 257  *               Add a deprecation warning for an option (or alias) by adding an entry in the
 258  *               "special_jvm_flags" table and setting the "deprecated_in" field.
 259  *               Often an option "deprecated" in one major release will
 260  *               be made "obsolete" in the next. In this case the entry should also have it's
 261  *               "obsolete_in" field set.
 262  *
 263  *     OBSOLETE: An option that has been removed (and deleted from globals.hpp), but is still accepted
 264  *               on the command line. A warning is printed to let the user know that option might not
 265  *               be accepted in the future.
 266  *
 267  *               Add an obsolete warning for an option by adding an entry in the "special_jvm_flags"
 268  *               table and setting the "obsolete_in" field.
 269  *
 270  *      EXPIRED: A deprecated or obsolete option that has an "accept_until" version less than or equal
 271  *               to the current JDK version. The system will flatly refuse to admit the existence of
 272  *               the flag. This allows a flag to die automatically over JDK releases.
 273  *
 274  *               Note that manual cleanup of expired options should be done at major JDK version upgrades:
 275  *                  - Newly expired options should be removed from the special_jvm_flags and aliased_jvm_flags tables.
 276  *                  - Newly obsolete or expired deprecated options should have their global variable
 277  *                    definitions removed (from globals.hpp, etc) and related implementations removed.
 278  *
 279  * Recommended approach for removing options:
 280  *
 281  * To remove options commonly used by customers (e.g. product, commercial -XX options), use
 282  * the 3-step model adding major release numbers to the deprecate, obsolete and expire columns.
 283  *
 284  * To remove internal options (e.g. diagnostic, experimental, develop options), use
 285  * a 2-step model adding major release numbers to the obsolete and expire columns.
 286  *
 287  * To change the name of an option, use the alias table as well as a 2-step
 288  * model adding major release numbers to the deprecate and expire columns.
 289  * Think twice about aliasing commonly used customer options.
 290  *
 291  * There are times when it is appropriate to leave a future release number as undefined.
 292  *
 293  * Tests:  Aliases should be tested in VMAliasOptions.java.
 294  *         Deprecated options should be tested in VMDeprecatedOptions.java.
 295  */
 296 
 297 // Obsolete or deprecated -XX flag.
 298 typedef struct {
 299   const char* name;
 300   JDK_Version deprecated_in; // When the deprecation warning started (or "undefined").
 301   JDK_Version obsolete_in;   // When the obsolete warning started (or "undefined").
 302   JDK_Version expired_in;    // When the option expires (or "undefined").
 303 } SpecialFlag;
 304 
 305 // The special_jvm_flags table declares options that are being deprecated and/or obsoleted. The
 306 // "deprecated_in" or "obsolete_in" fields may be set to "undefined", but not both.
 307 // When the JDK version reaches 'deprecated_in' limit, the JVM will process this flag on
 308 // the command-line as usual, but will issue a warning.
 309 // When the JDK version reaches 'obsolete_in' limit, the JVM will continue accepting this flag on
 310 // the command-line, while issuing a warning and ignoring the flag value.
 311 // Once the JDK version reaches 'expired_in' limit, the JVM will flatly refuse to admit the
 312 // existence of the flag.
 313 //
 314 // MANUAL CLEANUP ON JDK VERSION UPDATES:
 315 // This table ensures that the handling of options will update automatically when the JDK
 316 // version is incremented, but the source code needs to be cleanup up manually:
 317 // - As "deprecated" options age into "obsolete" or "expired" options, the associated "globals"
 318 //   variable should be removed, as well as users of the variable.
 319 // - As "deprecated" options age into "obsolete" options, move the entry into the
 320 //   "Obsolete Flags" section of the table.
 321 // - All expired options should be removed from the table.
 322 static SpecialFlag const special_jvm_flags[] = {
 323 #ifdef TEST_VERIFY_SPECIAL_JVM_FLAGS
 324   { "dep > obs",                    JDK_Version::jdk(9), JDK_Version::jdk(8), JDK_Version::undefined() },
 325   { "dep > exp ",                   JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(8) },
 326   { "obs > exp ",                   JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(8) },
 327   { "not deprecated or obsolete",   JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::undefined() },
 328   { "dup option",                   JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
 329   { "dup option",                   JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
 330   { "BytecodeVerificationRemote",   JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::undefined() },
 331 #endif
 332 
 333   // -------------- Deprecated Flags --------------
 334   // --- Non-alias flags - sorted by obsolete_in then expired_in:
 335   { "MaxGCMinorPauseMillis",        JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
 336   { "UseParNewGC",                  JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
 337 
 338   // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in:
 339   { "DefaultMaxRAMFraction",        JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
 340   { "CreateMinidumpOnCrash",        JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
 341   { "CMSMarkStackSizeMax",          JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
 342   { "CMSMarkStackSize",             JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
 343   { "G1MarkStackSize",              JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
 344   { "ParallelMarkingThreads",       JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
 345   { "ParallelCMSThreads",           JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
 346 
 347   // -------------- Obsolete Flags - sorted by expired_in --------------
 348   { "UseOldInlining",                JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 349   { "SafepointPollOffset",           JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 350   { "UseBoundThreads",               JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 351   { "DefaultThreadPriority",         JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 352   { "NoYieldsInMicrolock",           JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 353   { "BackEdgeThreshold",             JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 354   { "UseNewReflection",              JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 355   { "ReflectionWrapResolutionErrors",JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 356   { "VerifyReflectionBytecodes",     JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 357   { "AutoShutdownNMT",               JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 358   { "NmethodSweepFraction",          JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 359   { "NmethodSweepCheckInterval",     JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 360   { "CodeCacheMinimumFreeSpace",     JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 361 #ifndef ZERO
 362   { "UseFastAccessorMethods",        JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 363   { "UseFastEmptyMethods",           JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 364 #endif // ZERO
 365   { "UseCompilerSafepoints",         JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 366   { "AdaptiveSizePausePolicy",       JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 367   { "ParallelGCRetainPLAB",          JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 368   { "ThreadSafetyMargin",            JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 369   { "LazyBootClassLoader",           JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 370   { "StarvationMonitorInterval",     JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
 371   { "PreInflateSpin",                JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },






















 372   { NULL, JDK_Version(0), JDK_Version(0) }
 373 };
 374 
 375 // Flags that are aliases for other flags.
 376 typedef struct {
 377   const char* alias_name;
 378   const char* real_name;
 379 } AliasedFlag;
 380 
 381 static AliasedFlag const aliased_jvm_flags[] = {
 382   { "DefaultMaxRAMFraction",    "MaxRAMFraction"    },
 383   { "CMSMarkStackSizeMax",      "MarkStackSizeMax"  },
 384   { "CMSMarkStackSize",         "MarkStackSize"     },
 385   { "G1MarkStackSize",          "MarkStackSize"     },
 386   { "ParallelMarkingThreads",   "ConcGCThreads"     },
 387   { "ParallelCMSThreads",       "ConcGCThreads"     },
 388   { "CreateMinidumpOnCrash",    "CreateCoredumpOnCrash" },
 389   { NULL, NULL}
 390 };
 391 
 392 // Return true if "v" is less than "other", where "other" may be "undefined".
 393 static bool version_less_than(JDK_Version v, JDK_Version other) {
 394   assert(!v.is_undefined(), "must be defined");
 395   if (!other.is_undefined() && v.compare(other) >= 0) {
 396     return false;










 397   } else {
 398     return true;
 399   }
 400 }
 401 
 402 static bool lookup_special_flag(const char *flag_name, SpecialFlag& flag) {
 403   for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
 404     if ((strcmp(special_jvm_flags[i].name, flag_name) == 0)) {
 405       flag = special_jvm_flags[i];
 406       return true;
 407     }
 408   }
 409   return false;
 410 }
 411 
 412 bool Arguments::is_obsolete_flag(const char *flag_name, JDK_Version* version) {
 413   assert(version != NULL, "Must provide a version buffer");
 414   SpecialFlag flag;
 415   if (lookup_special_flag(flag_name, flag)) {
 416     if (!flag.obsolete_in.is_undefined()) {
 417       if (version_less_than(JDK_Version::current(), flag.expired_in)) {
 418         *version = flag.obsolete_in;
 419         return true;
 420       }
 421     }
 422   }
 423   return false;
 424 }
 425 
 426 int Arguments::is_deprecated_flag(const char *flag_name, JDK_Version* version) {
 427   assert(version != NULL, "Must provide a version buffer");
 428   SpecialFlag flag;
 429   if (lookup_special_flag(flag_name, flag)) {
 430     if (!flag.deprecated_in.is_undefined()) {
 431       if (version_less_than(JDK_Version::current(), flag.obsolete_in) &&
 432           version_less_than(JDK_Version::current(), flag.expired_in)) {
 433         *version = flag.deprecated_in;
 434         return 1;
 435       } else {
 436         return -1;
 437       }
 438     }
 439   }
 440   return 0;
 441 }
 442 
 443 const char* Arguments::real_flag_name(const char *flag_name) {
 444   for (size_t i = 0; aliased_jvm_flags[i].alias_name != NULL; i++) {
 445     const AliasedFlag& flag_status = aliased_jvm_flags[i];
 446     if (strcmp(flag_status.alias_name, flag_name) == 0) {
 447         return flag_status.real_name;
 448     }
 449   }
 450   return flag_name;
 451 }
 452 
 453 #ifndef PRODUCT
 454 static bool lookup_special_flag(const char *flag_name, size_t skip_index) {
 455   for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
 456     if ((i != skip_index) && (strcmp(special_jvm_flags[i].name, flag_name) == 0)) {
 457       return true;
 458     }
 459   }
 460   return false;
 461 }
 462 
 463 static bool verify_special_jvm_flags() {
 464   bool success = true;
 465   for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
 466     const SpecialFlag& flag = special_jvm_flags[i];
 467     if (lookup_special_flag(flag.name, i)) {
 468       warning("Duplicate special flag declaration \"%s\"", flag.name);
 469       success = false;
 470     }
 471     if (flag.deprecated_in.is_undefined() &&
 472         flag.obsolete_in.is_undefined()) {
 473       warning("Special flag entry \"%s\" must declare version deprecated and/or obsoleted in.", flag.name);
 474       success = false;
 475     }
 476 
 477     if (!flag.deprecated_in.is_undefined()) {
 478       if (!version_less_than(flag.deprecated_in, flag.obsolete_in)) {
 479         warning("Special flag entry \"%s\" must be deprecated before obsoleted.", flag.name);
 480         success = false;
 481       }
 482 
 483       if (!version_less_than(flag.deprecated_in, flag.expired_in)) {
 484         warning("Special flag entry \"%s\" must be deprecated before expired.", flag.name);
 485         success = false;
 486       }
 487     }
 488 
 489     if (!flag.obsolete_in.is_undefined()) {
 490       if (!version_less_than(flag.obsolete_in, flag.expired_in)) {
 491         warning("Special flag entry \"%s\" must be obsoleted before expired.", flag.name);
 492         success = false;
 493       }
 494 
 495       // if flag has become obsolete it should not have a "globals" flag defined anymore.
 496       if (!version_less_than(JDK_Version::current(), flag.obsolete_in)) {
 497         if (Flag::find_flag(flag.name) != NULL) {
 498           warning("Global variable for obsolete special flag entry \"%s\" should be removed", flag.name);
 499           success = false;
 500         }
 501       }
 502     }
 503 
 504     if (!flag.expired_in.is_undefined()) {
 505       // if flag has become expired it should not have a "globals" flag defined anymore.
 506       if (!version_less_than(JDK_Version::current(), flag.expired_in)) {
 507         if (Flag::find_flag(flag.name) != NULL) {
 508           warning("Global variable for expired flag entry \"%s\" should be removed", flag.name);
 509           success = false;
 510         }
 511       }
 512     }
 513 
 514   }
 515   return success;
 516 }
 517 #endif
 518 
 519 // Constructs the system class path (aka boot class path) from the following
 520 // components, in order:
 521 //
 522 //     prefix           // from -Xbootclasspath/p:...
 523 //     base             // from os::get_system_properties() or -Xbootclasspath=
 524 //     suffix           // from -Xbootclasspath/a:...
 525 //
 526 // This could be AllStatic, but it isn't needed after argument processing is
 527 // complete.
 528 class SysClassPath: public StackObj {
 529 public:
 530   SysClassPath(const char* base);
 531   ~SysClassPath();
 532 
 533   inline void set_base(const char* base);
 534   inline void add_prefix(const char* prefix);
 535   inline void add_suffix_to_prefix(const char* suffix);
 536   inline void add_suffix(const char* suffix);
 537   inline void reset_path(const char* base);
 538 


 876     // each new setting adds another LINE to the switch:
 877     sprintf(buf, "%s\n%s", old_value, new_value);
 878     value = buf;
 879     free_this_too = buf;
 880   }
 881   (void) CommandLineFlags::ccstrAtPut(name, &value, origin);
 882   // CommandLineFlags always returns a pointer that needs freeing.
 883   FREE_C_HEAP_ARRAY(char, value);
 884   if (free_this_too != NULL) {
 885     // CommandLineFlags made its own copy, so I must delete my own temp. buffer.
 886     FREE_C_HEAP_ARRAY(char, free_this_too);
 887   }
 888   return true;
 889 }
 890 
 891 const char* Arguments::handle_aliases_and_deprecation(const char* arg, bool warn) {
 892   const char* real_name = real_flag_name(arg);
 893   JDK_Version since = JDK_Version();
 894   switch (is_deprecated_flag(arg, &since)) {
 895     case -1:
 896       return NULL; // obsolete or expired, don't process normally
 897     case 0:
 898       return real_name;
 899     case 1: {
 900       if (warn) {
 901         char version[256];
 902         since.to_string(version, sizeof(version));
 903         if (real_name != arg) {
 904           warning("Option %s was deprecated in version %s and will likely be removed in a future release. Use option %s instead.",
 905                   arg, version, real_name);
 906         } else {
 907           warning("Option %s was deprecated in version %s and will likely be removed in a future release.",
 908                   arg, version);
 909         }
 910       }
 911       return real_name;
 912     }
 913   }
 914   ShouldNotReachHere();
 915   return NULL;
 916 }


3845       vm_exit(0);
3846     }
3847 #endif
3848   }
3849   return JNI_OK;
3850 }
3851 
3852 static void print_options(const JavaVMInitArgs *args) {
3853   const char* tail;
3854   for (int index = 0; index < args->nOptions; index++) {
3855     const JavaVMOption *option = args->options + index;
3856     if (match_option(option, "-XX:", &tail)) {
3857       logOption(tail);
3858     }
3859   }
3860 }
3861 
3862 // Parse entry point called from JNI_CreateJavaVM
3863 
3864 jint Arguments::parse(const JavaVMInitArgs* args) {
3865   assert(verify_special_jvm_flags(), "deprecated and obsolete flag table inconsistent");
3866 
3867   // Initialize ranges and constraints
3868   CommandLineFlagRangeList::init();
3869   CommandLineFlagConstraintList::init();
3870 
3871   // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed.
3872   const char* hotspotrc = ".hotspotrc";
3873   char* flags_file = NULL;
3874   bool settings_file_specified = false;
3875   bool needs_hotspotrc_warning = false;
3876   ScopedVMInitArgs java_tool_options_args;
3877   ScopedVMInitArgs java_options_args;
3878 
3879   jint code =
3880       parse_java_tool_options_environment_variable(&java_tool_options_args);
3881   if (code != JNI_OK) {
3882     return code;
3883   }
3884 
3885   code = parse_java_options_environment_variable(&java_options_args);


< prev index next >