src/hotspot/share/runtime/arguments.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Sdiff src/hotspot/share/runtime

src/hotspot/share/runtime/arguments.cpp

Print this page




 365 // existence of the flag.
 366 //
 367 // MANUAL CLEANUP ON JDK VERSION UPDATES:
 368 // This table ensures that the handling of options will update automatically when the JDK
 369 // version is incremented, but the source code needs to be cleanup up manually:
 370 // - As "deprecated" options age into "obsolete" or "expired" options, the associated "globals"
 371 //   variable should be removed, as well as users of the variable.
 372 // - As "deprecated" options age into "obsolete" options, move the entry into the
 373 //   "Obsolete Flags" section of the table.
 374 // - All expired options should be removed from the table.
 375 static SpecialFlag const special_jvm_flags[] = {
 376   // -------------- Deprecated Flags --------------
 377   // --- Non-alias flags - sorted by obsolete_in then expired_in:
 378   { "MaxGCMinorPauseMillis",        JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
 379   { "UseConcMarkSweepGC",           JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
 380   { "AssumeMP",                     JDK_Version::jdk(10),JDK_Version::undefined(), JDK_Version::undefined() },
 381   { "MonitorInUseLists",            JDK_Version::jdk(10),JDK_Version::undefined(), JDK_Version::undefined() },
 382   { "MaxRAMFraction",               JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
 383   { "MinRAMFraction",               JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
 384   { "InitialRAMFraction",           JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },

 385 
 386   // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in:
 387   { "DefaultMaxRAMFraction",        JDK_Version::jdk(8),  JDK_Version::undefined(), JDK_Version::undefined() },
 388   { "CreateMinidumpOnCrash",        JDK_Version::jdk(9),  JDK_Version::undefined(), JDK_Version::undefined() },
 389   { "MustCallLoadClassInternal",    JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
 390   { "UnsyncloadClass",              JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
 391 
 392   // -------------- Obsolete Flags - sorted by expired_in --------------
 393   { "ConvertSleepToYield",           JDK_Version::jdk(9),      JDK_Version::jdk(10), JDK_Version::jdk(11) },
 394   { "ConvertYieldToSleep",           JDK_Version::jdk(9),      JDK_Version::jdk(10), JDK_Version::jdk(11) },
 395   { "MinSleepInterval",              JDK_Version::jdk(9),      JDK_Version::jdk(10), JDK_Version::jdk(11) },
 396   { "PermSize",                      JDK_Version::undefined(), JDK_Version::jdk(8),  JDK_Version::undefined() },
 397   { "MaxPermSize",                   JDK_Version::undefined(), JDK_Version::jdk(8),  JDK_Version::undefined() },
 398 
 399 #ifdef TEST_VERIFY_SPECIAL_JVM_FLAGS
 400   { "dep > obs",                    JDK_Version::jdk(9), JDK_Version::jdk(8), JDK_Version::undefined() },
 401   { "dep > exp ",                   JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(8) },
 402   { "obs > exp ",                   JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(8) },
 403   { "not deprecated or obsolete",   JDK_Version::undefined(), JDK_Version::undefined(), JDK_Version::jdk(9) },
 404   { "dup option",                   JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },


2663   // Parse args structure generated from JAVA_TOOL_OPTIONS environment
2664   // variable (if present).
2665   jint result = parse_each_vm_init_arg(java_tool_options_args, &patch_mod_javabase, Flag::ENVIRON_VAR);
2666   if (result != JNI_OK) {
2667     return result;
2668   }
2669 
2670   // Parse args structure generated from the command line flags.
2671   result = parse_each_vm_init_arg(cmd_line_args, &patch_mod_javabase, Flag::COMMAND_LINE);
2672   if (result != JNI_OK) {
2673     return result;
2674   }
2675 
2676   // Parse args structure generated from the _JAVA_OPTIONS environment
2677   // variable (if present) (mimics classic VM)
2678   result = parse_each_vm_init_arg(java_options_args, &patch_mod_javabase, Flag::ENVIRON_VAR);
2679   if (result != JNI_OK) {
2680     return result;
2681   }
2682 








2683   // Do final processing now that all arguments have been parsed
2684   result = finalize_vm_init_args(patch_mod_javabase);
2685   if (result != JNI_OK) {
2686     return result;
2687   }
2688 
2689   return JNI_OK;
2690 }
2691 
2692 // Checks if name in command-line argument -agent{lib,path}:name[=options]
2693 // represents a valid JDWP agent.  is_path==true denotes that we
2694 // are dealing with -agentpath (case where name is a path), otherwise with
2695 // -agentlib
2696 bool valid_jdwp_agent(char *name, bool is_path) {
2697   char *_name;
2698   const char *_jdwp = "jdwp";
2699   size_t _len_jdwp, _len_prefix;
2700 
2701   if (is_path) {
2702     if ((_name = strrchr(name, (int) *os::file_separator())) == NULL) {


3338         return JNI_EINVAL;
3339       }
3340     // JNI hooks
3341     } else if (match_option(option, "-Xcheck", &tail)) {
3342       if (!strcmp(tail, ":jni")) {
3343 #if !INCLUDE_JNI_CHECK
3344         warning("JNI CHECKING is not supported in this VM");
3345 #else
3346         CheckJNICalls = true;
3347 #endif // INCLUDE_JNI_CHECK
3348       } else if (is_bad_option(option, args->ignoreUnrecognized,
3349                                      "check")) {
3350         return JNI_EINVAL;
3351       }
3352     } else if (match_option(option, "vfprintf")) {
3353       _vfprintf_hook = CAST_TO_FN_PTR(vfprintf_hook_t, option->extraInfo);
3354     } else if (match_option(option, "exit")) {
3355       _exit_hook = CAST_TO_FN_PTR(exit_hook_t, option->extraInfo);
3356     } else if (match_option(option, "abort")) {
3357       _abort_hook = CAST_TO_FN_PTR(abort_hook_t, option->extraInfo);
3358     // -XX:+AggressiveHeap
3359     } else if (match_option(option, "-XX:+AggressiveHeap")) {
3360       jint result = set_aggressive_heap_flags();
3361       if (result != JNI_OK) {
3362           return result;
3363       }
3364     // Need to keep consistency of MaxTenuringThreshold and AlwaysTenure/NeverTenure;
3365     // and the last option wins.
3366     } else if (match_option(option, "-XX:+NeverTenure")) {
3367       if (FLAG_SET_CMDLINE(bool, NeverTenure, true) != Flag::SUCCESS) {
3368         return JNI_EINVAL;
3369       }
3370       if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != Flag::SUCCESS) {
3371         return JNI_EINVAL;
3372       }
3373       if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, markOopDesc::max_age + 1) != Flag::SUCCESS) {
3374         return JNI_EINVAL;
3375       }
3376     } else if (match_option(option, "-XX:+AlwaysTenure")) {
3377       if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != Flag::SUCCESS) {
3378         return JNI_EINVAL;
3379       }
3380       if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != Flag::SUCCESS) {
3381         return JNI_EINVAL;
3382       }
3383       if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0) != Flag::SUCCESS) {


3623     }
3624   }
3625 
3626   DIR* dir = os::opendir(path);
3627   if (dir != NULL) {
3628     jio_fprintf(defaultStream::output_stream(),
3629       "<JAVA_HOME>/lib/endorsed is not supported. Endorsed standards and standalone APIs\n"
3630       "in modular form will be supported via the concept of upgradeable modules.\n");
3631     os::closedir(dir);
3632     return JNI_ERR;
3633   }
3634 
3635   jio_snprintf(path, JVM_MAXPATHLEN, "%s%slib%sext", Arguments::get_java_home(), fileSep, fileSep);
3636   dir = os::opendir(path);
3637   if (dir != NULL) {
3638     jio_fprintf(defaultStream::output_stream(),
3639       "<JAVA_HOME>/lib/ext exists, extensions mechanism no longer supported; "
3640       "Use -classpath instead.\n.");
3641     os::closedir(dir);
3642     return JNI_ERR;










3643   }
3644 
3645   // This must be done after all arguments have been processed.
3646   // java_compiler() true means set to "NONE" or empty.
3647   if (java_compiler() && !xdebug_mode()) {
3648     // For backwards compatibility, we switch to interpreted mode if
3649     // -Djava.compiler="NONE" or "" is specified AND "-Xdebug" was
3650     // not specified.
3651     set_mode_flags(_int);
3652   }
3653 
3654   // CompileThresholdScaling == 0.0 is same as -Xint: Disable compilation (enable interpreter-only mode),
3655   // but like -Xint, leave compilation thresholds unaffected.
3656   // With tiered compilation disabled, setting CompileThreshold to 0 disables compilation as well.
3657   if ((CompileThresholdScaling == 0.0) || (!TieredCompilation && CompileThreshold == 0)) {
3658     set_mode_flags(_int);
3659   }
3660 
3661   // eventually fix up InitialTenuringThreshold if only MaxTenuringThreshold is set
3662   if (FLAG_IS_DEFAULT(InitialTenuringThreshold) && (InitialTenuringThreshold > MaxTenuringThreshold)) {




 365 // existence of the flag.
 366 //
 367 // MANUAL CLEANUP ON JDK VERSION UPDATES:
 368 // This table ensures that the handling of options will update automatically when the JDK
 369 // version is incremented, but the source code needs to be cleanup up manually:
 370 // - As "deprecated" options age into "obsolete" or "expired" options, the associated "globals"
 371 //   variable should be removed, as well as users of the variable.
 372 // - As "deprecated" options age into "obsolete" options, move the entry into the
 373 //   "Obsolete Flags" section of the table.
 374 // - All expired options should be removed from the table.
 375 static SpecialFlag const special_jvm_flags[] = {
 376   // -------------- Deprecated Flags --------------
 377   // --- Non-alias flags - sorted by obsolete_in then expired_in:
 378   { "MaxGCMinorPauseMillis",        JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
 379   { "UseConcMarkSweepGC",           JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
 380   { "AssumeMP",                     JDK_Version::jdk(10),JDK_Version::undefined(), JDK_Version::undefined() },
 381   { "MonitorInUseLists",            JDK_Version::jdk(10),JDK_Version::undefined(), JDK_Version::undefined() },
 382   { "MaxRAMFraction",               JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
 383   { "MinRAMFraction",               JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
 384   { "InitialRAMFraction",           JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
 385   { "UseCGroupMemoryLimitForHeap",  JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::jdk(11) },
 386 
 387   // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in:
 388   { "DefaultMaxRAMFraction",        JDK_Version::jdk(8),  JDK_Version::undefined(), JDK_Version::undefined() },
 389   { "CreateMinidumpOnCrash",        JDK_Version::jdk(9),  JDK_Version::undefined(), JDK_Version::undefined() },
 390   { "MustCallLoadClassInternal",    JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
 391   { "UnsyncloadClass",              JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
 392 
 393   // -------------- Obsolete Flags - sorted by expired_in --------------
 394   { "ConvertSleepToYield",           JDK_Version::jdk(9),      JDK_Version::jdk(10), JDK_Version::jdk(11) },
 395   { "ConvertYieldToSleep",           JDK_Version::jdk(9),      JDK_Version::jdk(10), JDK_Version::jdk(11) },
 396   { "MinSleepInterval",              JDK_Version::jdk(9),      JDK_Version::jdk(10), JDK_Version::jdk(11) },
 397   { "PermSize",                      JDK_Version::undefined(), JDK_Version::jdk(8),  JDK_Version::undefined() },
 398   { "MaxPermSize",                   JDK_Version::undefined(), JDK_Version::jdk(8),  JDK_Version::undefined() },
 399 
 400 #ifdef TEST_VERIFY_SPECIAL_JVM_FLAGS
 401   { "dep > obs",                    JDK_Version::jdk(9), JDK_Version::jdk(8), JDK_Version::undefined() },
 402   { "dep > exp ",                   JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(8) },
 403   { "obs > exp ",                   JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(8) },
 404   { "not deprecated or obsolete",   JDK_Version::undefined(), JDK_Version::undefined(), JDK_Version::jdk(9) },
 405   { "dup option",                   JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },


2664   // Parse args structure generated from JAVA_TOOL_OPTIONS environment
2665   // variable (if present).
2666   jint result = parse_each_vm_init_arg(java_tool_options_args, &patch_mod_javabase, Flag::ENVIRON_VAR);
2667   if (result != JNI_OK) {
2668     return result;
2669   }
2670 
2671   // Parse args structure generated from the command line flags.
2672   result = parse_each_vm_init_arg(cmd_line_args, &patch_mod_javabase, Flag::COMMAND_LINE);
2673   if (result != JNI_OK) {
2674     return result;
2675   }
2676 
2677   // Parse args structure generated from the _JAVA_OPTIONS environment
2678   // variable (if present) (mimics classic VM)
2679   result = parse_each_vm_init_arg(java_options_args, &patch_mod_javabase, Flag::ENVIRON_VAR);
2680   if (result != JNI_OK) {
2681     return result;
2682   }
2683 
2684   // We need to ensure processor and memory resources have been properly
2685   // configured - which may rely on arguments we just processed - before
2686   // doing the final argument processing. Any argument processing that
2687   // needs to know about processor and memory resources must occur after
2688   // this point.
2689 
2690   os::init_container_support();
2691 
2692   // Do final processing now that all arguments have been parsed
2693   result = finalize_vm_init_args(patch_mod_javabase);
2694   if (result != JNI_OK) {
2695     return result;
2696   }
2697 
2698   return JNI_OK;
2699 }
2700 
2701 // Checks if name in command-line argument -agent{lib,path}:name[=options]
2702 // represents a valid JDWP agent.  is_path==true denotes that we
2703 // are dealing with -agentpath (case where name is a path), otherwise with
2704 // -agentlib
2705 bool valid_jdwp_agent(char *name, bool is_path) {
2706   char *_name;
2707   const char *_jdwp = "jdwp";
2708   size_t _len_jdwp, _len_prefix;
2709 
2710   if (is_path) {
2711     if ((_name = strrchr(name, (int) *os::file_separator())) == NULL) {


3347         return JNI_EINVAL;
3348       }
3349     // JNI hooks
3350     } else if (match_option(option, "-Xcheck", &tail)) {
3351       if (!strcmp(tail, ":jni")) {
3352 #if !INCLUDE_JNI_CHECK
3353         warning("JNI CHECKING is not supported in this VM");
3354 #else
3355         CheckJNICalls = true;
3356 #endif // INCLUDE_JNI_CHECK
3357       } else if (is_bad_option(option, args->ignoreUnrecognized,
3358                                      "check")) {
3359         return JNI_EINVAL;
3360       }
3361     } else if (match_option(option, "vfprintf")) {
3362       _vfprintf_hook = CAST_TO_FN_PTR(vfprintf_hook_t, option->extraInfo);
3363     } else if (match_option(option, "exit")) {
3364       _exit_hook = CAST_TO_FN_PTR(exit_hook_t, option->extraInfo);
3365     } else if (match_option(option, "abort")) {
3366       _abort_hook = CAST_TO_FN_PTR(abort_hook_t, option->extraInfo);






3367     // Need to keep consistency of MaxTenuringThreshold and AlwaysTenure/NeverTenure;
3368     // and the last option wins.
3369     } else if (match_option(option, "-XX:+NeverTenure")) {
3370       if (FLAG_SET_CMDLINE(bool, NeverTenure, true) != Flag::SUCCESS) {
3371         return JNI_EINVAL;
3372       }
3373       if (FLAG_SET_CMDLINE(bool, AlwaysTenure, false) != Flag::SUCCESS) {
3374         return JNI_EINVAL;
3375       }
3376       if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, markOopDesc::max_age + 1) != Flag::SUCCESS) {
3377         return JNI_EINVAL;
3378       }
3379     } else if (match_option(option, "-XX:+AlwaysTenure")) {
3380       if (FLAG_SET_CMDLINE(bool, NeverTenure, false) != Flag::SUCCESS) {
3381         return JNI_EINVAL;
3382       }
3383       if (FLAG_SET_CMDLINE(bool, AlwaysTenure, true) != Flag::SUCCESS) {
3384         return JNI_EINVAL;
3385       }
3386       if (FLAG_SET_CMDLINE(uintx, MaxTenuringThreshold, 0) != Flag::SUCCESS) {


3626     }
3627   }
3628 
3629   DIR* dir = os::opendir(path);
3630   if (dir != NULL) {
3631     jio_fprintf(defaultStream::output_stream(),
3632       "<JAVA_HOME>/lib/endorsed is not supported. Endorsed standards and standalone APIs\n"
3633       "in modular form will be supported via the concept of upgradeable modules.\n");
3634     os::closedir(dir);
3635     return JNI_ERR;
3636   }
3637 
3638   jio_snprintf(path, JVM_MAXPATHLEN, "%s%slib%sext", Arguments::get_java_home(), fileSep, fileSep);
3639   dir = os::opendir(path);
3640   if (dir != NULL) {
3641     jio_fprintf(defaultStream::output_stream(),
3642       "<JAVA_HOME>/lib/ext exists, extensions mechanism no longer supported; "
3643       "Use -classpath instead.\n.");
3644     os::closedir(dir);
3645     return JNI_ERR;
3646   }
3647 
3648   // This must be done after all arguments have been processed
3649   // and the container support has been initialized since AggressiveHeap
3650   // relies on the amount of total memory available.
3651   if (AggressiveHeap) {
3652     jint result = set_aggressive_heap_flags();
3653     if (result != JNI_OK) {
3654       return result;
3655     }
3656   }
3657 
3658   // This must be done after all arguments have been processed.
3659   // java_compiler() true means set to "NONE" or empty.
3660   if (java_compiler() && !xdebug_mode()) {
3661     // For backwards compatibility, we switch to interpreted mode if
3662     // -Djava.compiler="NONE" or "" is specified AND "-Xdebug" was
3663     // not specified.
3664     set_mode_flags(_int);
3665   }
3666 
3667   // CompileThresholdScaling == 0.0 is same as -Xint: Disable compilation (enable interpreter-only mode),
3668   // but like -Xint, leave compilation thresholds unaffected.
3669   // With tiered compilation disabled, setting CompileThreshold to 0 disables compilation as well.
3670   if ((CompileThresholdScaling == 0.0) || (!TieredCompilation && CompileThreshold == 0)) {
3671     set_mode_flags(_int);
3672   }
3673 
3674   // eventually fix up InitialTenuringThreshold if only MaxTenuringThreshold is set
3675   if (FLAG_IS_DEFAULT(InitialTenuringThreshold) && (InitialTenuringThreshold > MaxTenuringThreshold)) {


src/hotspot/share/runtime/arguments.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File