< prev index next >

src/share/vm/runtime/arguments.cpp

Print this page
rev 8867 : imported patch 8066821.rev6
rev 8868 : imported patch 8066821.rev7
rev 8869 : [mq]: 8066821.v8


 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  *               "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  * 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 // MAINTENANCE 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, push the entry below into the
 320 //   "Obsolete Flags" section.
 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:
 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):
 339   { "DefaultMaxRAMFraction",        JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
 340   { "CMSMarkStackSizeMax",          JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
 341   { "CMSMarkStackSize",             JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
 342   { "G1MarkStackSize",              JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
 343   { "ParallelMarkingThreads",       JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
 344   { "ParallelCMSThreads",           JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
 345   { "CreateMinidumpOnCrash",        JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
 346 
 347   // -------------- Obsolete Flags --------------
 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 // Returns 1 if the flag is special and jdk version is in the range specified.
 413 //     In this case the 'version' buffer is filled in with the version number when
 414 //     the flag became special.
 415 // Returns -1 if the flag is the wrong kind of special - expired or (check_deprecated & obsolete).
 416 // Returns 0 if the flag is not special.
 417 // "flag_name" is a flag name stripped of '+', '-', and '='.
 418 static int is_special_flag(bool check_deprecated, const char *flag_name, JDK_Version* version) {
 419   assert(version != NULL, "Must provide a version buffer");
 420   SpecialFlag flag;
 421   if (lookup_special_flag(flag_name, flag)) {
 422     if (check_deprecated && !flag.deprecated_in.is_undefined()) {
 423       if (version_less_than(JDK_Version::current(), flag.obsolete_in) &&
 424           version_less_than(JDK_Version::current(), flag.expired_in)) {
 425         *version = flag.deprecated_in;
 426         return 1;
 427       } else {
 428         return -1;
 429       }
 430     } else if (!check_deprecated && !flag.obsolete_in.is_undefined()) {
 431        if (version_less_than(JDK_Version::current(), flag.expired_in)) {
 432         *version = flag.obsolete_in;
 433         return 1;
 434       } else {
 435         return -1;
 436       }
 437     }
 438   }
 439   return 0;
 440 }
 441 
 442 bool Arguments::is_obsolete_flag(const char *flag_name, JDK_Version* version) {
 443   return (is_special_flag(false, flag_name, version) == 1);
 444 }
 445 
 446 int Arguments::is_deprecated_flag(const char *flag_name, JDK_Version* version) {
 447   return is_special_flag(true, flag_name, version);
 448 }
 449 
 450 const char* Arguments::real_flag_name(const char *flag_name) {
 451   for (size_t i = 0; aliased_jvm_flags[i].alias_name != NULL; i++) {
 452     const AliasedFlag& flag_status = aliased_jvm_flags[i];
 453     if (strcmp(flag_status.alias_name, flag_name) == 0) {
 454         return flag_status.real_name;
 455     }
 456   }
 457   return flag_name;
 458 }
 459 
 460 #ifndef PRODUCT
 461 static bool lookup_special_flag(const char *flag_name, size_t skip_index) {
 462   for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
 463     if ((i != skip_index) && (strcmp(special_jvm_flags[i].name, flag_name) == 0)) {
 464       return true;
 465     }
 466   }
 467   return false;
 468 }
 469 
 470 static bool verify_special_jvm_flags() {
 471   bool success = true;
 472   for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
 473     const SpecialFlag& flag = special_jvm_flags[i];
 474     if (lookup_special_flag(flag.name, i)) {
 475       warning("Duplicate special flag declaration \"%s\"", flag.name);
 476       success = false;
 477     }
 478     if (flag.deprecated_in.is_undefined() &&
 479         flag.obsolete_in.is_undefined()) {
 480       warning("Special flag entry \"%s\" must declare version deprecated and/or obsoleted in.", flag.name);
 481       success = false;
 482     }
 483 
 484     if (!flag.deprecated_in.is_undefined()) {
 485       if (!version_less_than(flag.deprecated_in, flag.obsolete_in)) {
 486         warning("Special flag entry \"%s\" must be deprecated before obsoleted.", flag.name);
 487         success = false;
 488       }
 489 
 490       if (!version_less_than(flag.deprecated_in, flag.expired_in)) {
 491         warning("Special flag entry \"%s\" must be deprecated before expired.", flag.name);
 492         success = false;
 493       }
 494     }
 495 
 496     if (!flag.obsolete_in.is_undefined()) {
 497       if (!version_less_than(flag.obsolete_in, flag.expired_in)) {
 498         warning("Special flag entry \"%s\" must be obsoleted before expired.", flag.name);
 499         success = false;
 500       }
 501 
 502       // if flag has become obsolete it should not have a "globals" flag defined anymore.
 503       if (!version_less_than(JDK_Version::current(), flag.obsolete_in)) {
 504         if (Flag::find_flag(flag.name) != NULL) {
 505           warning("Global variable for obsolete special flag entry \"%s\" should be removed", flag.name);
 506           success = false;
 507         }
 508       }
 509     }
 510 
 511     if (!flag.expired_in.is_undefined()) {
 512       // if flag has become expired it should not have a "globals" flag defined anymore.
 513       if (!version_less_than(JDK_Version::current(), flag.expired_in)) {
 514         if (Flag::find_flag(flag.name) != NULL) {
 515           warning("Global variable for expired flag entry \"%s\" should be removed", flag.name);
 516           success = false;
 517         }
 518       }
 519     }
 520 
 521   }
 522   return success;
 523 }
 524 #endif
 525 
 526 // Constructs the system class path (aka boot class path) from the following
 527 // components, in order:
 528 //
 529 //     prefix           // from -Xbootclasspath/p:...
 530 //     base             // from os::get_system_properties() or -Xbootclasspath=
 531 //     suffix           // from -Xbootclasspath/a:...
 532 //
 533 // This could be AllStatic, but it isn't needed after argument processing is
 534 // complete.
 535 class SysClassPath: public StackObj {
 536 public:
 537   SysClassPath(const char* base);
 538   ~SysClassPath();
 539 
 540   inline void set_base(const char* base);
 541   inline void add_prefix(const char* prefix);
 542   inline void add_suffix_to_prefix(const char* suffix);
 543   inline void add_suffix(const char* suffix);
 544   inline void reset_path(const char* base);
 545 


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


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


< prev index next >