src/share/vm/runtime/arguments.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File aliastable.04 Sdiff src/share/vm/runtime

src/share/vm/runtime/arguments.cpp

Print this page




  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoader.hpp"
  27 #include "classfile/javaAssertions.hpp"
  28 #include "classfile/stringTable.hpp"
  29 #include "classfile/symbolTable.hpp"
  30 #include "code/codeCacheExtensions.hpp"
  31 #include "gc/shared/cardTableRS.hpp"
  32 #include "gc/shared/genCollectedHeap.hpp"
  33 #include "gc/shared/referenceProcessor.hpp"
  34 #include "gc/shared/taskqueue.hpp"
  35 #include "logging/log.hpp"

  36 #include "logging/logConfiguration.hpp"
  37 #include "memory/allocation.inline.hpp"
  38 #include "memory/universe.inline.hpp"
  39 #include "oops/oop.inline.hpp"
  40 #include "prims/jvmtiExport.hpp"
  41 #include "runtime/arguments.hpp"
  42 #include "runtime/arguments_ext.hpp"
  43 #include "runtime/commandLineFlagConstraintList.hpp"
  44 #include "runtime/commandLineFlagRangeList.hpp"
  45 #include "runtime/globals.hpp"
  46 #include "runtime/globals_extension.hpp"
  47 #include "runtime/java.hpp"
  48 #include "runtime/os.hpp"
  49 #include "runtime/vm_version.hpp"
  50 #include "services/management.hpp"
  51 #include "services/memTracker.hpp"
  52 #include "utilities/defaultStream.hpp"
  53 #include "utilities/macros.hpp"
  54 #include "utilities/stringUtils.hpp"
  55 #if INCLUDE_JVMCI


 382   { NULL, JDK_Version(0), JDK_Version(0) }
 383 };
 384 
 385 // Flags that are aliases for other flags.
 386 typedef struct {
 387   const char* alias_name;
 388   const char* real_name;
 389 } AliasedFlag;
 390 
 391 static AliasedFlag const aliased_jvm_flags[] = {
 392   { "DefaultMaxRAMFraction",    "MaxRAMFraction"    },
 393   { "CMSMarkStackSizeMax",      "MarkStackSizeMax"  },
 394   { "CMSMarkStackSize",         "MarkStackSize"     },
 395   { "G1MarkStackSize",          "MarkStackSize"     },
 396   { "ParallelMarkingThreads",   "ConcGCThreads"     },
 397   { "ParallelCMSThreads",       "ConcGCThreads"     },
 398   { "CreateMinidumpOnCrash",    "CreateCoredumpOnCrash" },
 399   { NULL, NULL}
 400 };
 401 
 402 static AliasedFlag const aliased_jvm_logging_flags[] = {
 403   { "-XX:+TraceClassResolution", "-Xlog:classresolve=info"},
 404   { "-XX:-TraceClassResolution", "-Xlog:classresolve=off"},
 405   { "-XX:+TraceExceptions", "-Xlog:exceptions=info" },
 406   { "-XX:-TraceExceptions", "-Xlog:exceptions=off" },
 407   { "-XX:+TraceMonitorInflation", "-Xlog:monitorinflation=debug" },
 408   { "-XX:-TraceMonitorInflation", "-Xlog:monitorinflation=off" },
 409   { NULL, NULL }
 410 };
 411 
 412 // Return true if "v" is less than "other", where "other" may be "undefined".
 413 static bool version_less_than(JDK_Version v, JDK_Version other) {
 414   assert(!v.is_undefined(), "must be defined");
 415   if (!other.is_undefined() && v.compare(other) >= 0) {
 416     return false;
 417   } else {
 418     return true;
 419   }
 420 }
 421 
 422 static bool lookup_special_flag(const char *flag_name, SpecialFlag& flag) {
 423   for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
 424     if ((strcmp(special_jvm_flags[i].name, flag_name) == 0)) {
 425       flag = special_jvm_flags[i];
 426       return true;
 427     }
 428   }
 429   return false;


 922       return real_name;
 923     case 1: {
 924       if (warn) {
 925         char version[256];
 926         since.to_string(version, sizeof(version));
 927         if (real_name != arg) {
 928           warning("Option %s was deprecated in version %s and will likely be removed in a future release. Use option %s instead.",
 929                   arg, version, real_name);
 930         } else {
 931           warning("Option %s was deprecated in version %s and will likely be removed in a future release.",
 932                   arg, version);
 933         }
 934       }
 935       return real_name;
 936     }
 937   }
 938   ShouldNotReachHere();
 939   return NULL;
 940 }
 941 
 942 // lookup_logging_aliases
 943 // Called from parse_each_vm_init_arg(). Should be called on -XX options before specific cases are checked.
 944 // If arg matches any aliased_jvm_logging_flags entry, look up the real name and copy it into buffer.
 945 bool Arguments::lookup_logging_aliases(const char* arg, char* buffer) {
 946   for (size_t i = 0; aliased_jvm_logging_flags[i].alias_name != NULL; i++) {
 947     const AliasedFlag& flag_status = aliased_jvm_logging_flags[i];
 948     if (strcmp(flag_status.alias_name, arg) == 0) {
 949       strcpy(buffer, flag_status.real_name);
 950       return true;
 951     }
 952   }
 953   return false;

 954 }
 955 
 956 bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
 957 
 958   // range of acceptable characters spelled out for portability reasons
 959 #define NAME_RANGE  "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]"
 960 #define BUFLEN 255
 961   char name[BUFLEN+1];
 962   char dummy;
 963   const char* real_name;
 964   bool warn_if_deprecated = true;

 965 
 966   if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {





 967     real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
 968     if (real_name == NULL) {
 969       return false;
 970     }
 971     return set_bool_flag(real_name, false, origin);
 972   }
 973   if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {





 974     real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
 975     if (real_name == NULL) {
 976       return false;
 977     }
 978     return set_bool_flag(real_name, true, origin);
 979   }
 980 
 981   char punct;
 982   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') {
 983     const char* value = strchr(arg, '=') + 1;
 984     Flag* flag;
 985 
 986     // this scanf pattern matches both strings (handled here) and numbers (handled later))
 987     real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
 988     if (real_name == NULL) {
 989       return false;
 990     }
 991     flag = Flag::find_flag(real_name);
 992     if (flag != NULL && flag->is_ccstr()) {
 993       if (flag->ccstr_accumulates()) {


2612   }
2613 
2614   if (strcmp(name, _jdwp) == 0) {
2615     return true;
2616   }
2617 
2618   return false;
2619 }
2620 
2621 jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
2622                                        SysClassPath* scp_p,
2623                                        bool* scp_assembly_required_p,
2624                                        Flag::Flags origin) {
2625   // Remaining part of option string
2626   const char* tail;
2627 
2628   // iterate over arguments
2629   for (int index = 0; index < args->nOptions; index++) {
2630     bool is_absolute_path = false;  // for -agentpath vs -agentlib
2631 
2632     JavaVMOption* option = args->options + index;
2633 
2634     if (!match_option(option, "-Djava.class.path", &tail) &&
2635         !match_option(option, "-Dsun.java.command", &tail) &&
2636         !match_option(option, "-Dsun.java.launcher", &tail)) {
2637 
2638         // add all jvm options to the jvm_args string. This string
2639         // is used later to set the java.vm.args PerfData string constant.
2640         // the -Djava.class.path and the -Dsun.java.command options are
2641         // omitted from jvm_args string as each have their own PerfData
2642         // string constant object.
2643         build_jvm_args(option->optionString);
2644     }
2645 
2646     // char buffer to store looked up logging option.
2647     char aliased_logging_option[256];
2648 
2649     // Catch -XX options which are aliased to Unified logging commands.
2650     if (match_option(option, "-XX:", &tail)) {
2651       if (lookup_logging_aliases(option->optionString, aliased_logging_option)) {
2652         option->optionString = aliased_logging_option;
2653       }
2654     }
2655 
2656     // -verbose:[class/gc/jni]
2657     if (match_option(option, "-verbose", &tail)) {
2658       if (!strcmp(tail, ":class") || !strcmp(tail, "")) {
2659         if (FLAG_SET_CMDLINE(bool, TraceClassLoading, true) != Flag::SUCCESS) {
2660           return JNI_EINVAL;
2661         }
2662         if (FLAG_SET_CMDLINE(bool, TraceClassUnloading, true) != Flag::SUCCESS) {
2663           return JNI_EINVAL;
2664         }
2665       } else if (!strcmp(tail, ":gc")) {
2666         // LogConfiguration_lock is not set up yet, but this code is executed by a single thread
2667         bool ret = LogConfiguration::parse_log_arguments("stdout", "gc", NULL, NULL, NULL);
2668         if (!ret) {
2669           return JNI_EINVAL;
2670         }
2671       } else if (!strcmp(tail, ":jni")) {
2672         if (FLAG_SET_CMDLINE(bool, PrintJNIResolving, true) != Flag::SUCCESS) {
2673           return JNI_EINVAL;




  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoader.hpp"
  27 #include "classfile/javaAssertions.hpp"
  28 #include "classfile/stringTable.hpp"
  29 #include "classfile/symbolTable.hpp"
  30 #include "code/codeCacheExtensions.hpp"
  31 #include "gc/shared/cardTableRS.hpp"
  32 #include "gc/shared/genCollectedHeap.hpp"
  33 #include "gc/shared/referenceProcessor.hpp"
  34 #include "gc/shared/taskqueue.hpp"
  35 #include "logging/log.hpp"
  36 #include "logging/logTag.hpp"
  37 #include "logging/logConfiguration.hpp"
  38 #include "memory/allocation.inline.hpp"
  39 #include "memory/universe.inline.hpp"
  40 #include "oops/oop.inline.hpp"
  41 #include "prims/jvmtiExport.hpp"
  42 #include "runtime/arguments.hpp"
  43 #include "runtime/arguments_ext.hpp"
  44 #include "runtime/commandLineFlagConstraintList.hpp"
  45 #include "runtime/commandLineFlagRangeList.hpp"
  46 #include "runtime/globals.hpp"
  47 #include "runtime/globals_extension.hpp"
  48 #include "runtime/java.hpp"
  49 #include "runtime/os.hpp"
  50 #include "runtime/vm_version.hpp"
  51 #include "services/management.hpp"
  52 #include "services/memTracker.hpp"
  53 #include "utilities/defaultStream.hpp"
  54 #include "utilities/macros.hpp"
  55 #include "utilities/stringUtils.hpp"
  56 #if INCLUDE_JVMCI


 383   { NULL, JDK_Version(0), JDK_Version(0) }
 384 };
 385 
 386 // Flags that are aliases for other flags.
 387 typedef struct {
 388   const char* alias_name;
 389   const char* real_name;
 390 } AliasedFlag;
 391 
 392 static AliasedFlag const aliased_jvm_flags[] = {
 393   { "DefaultMaxRAMFraction",    "MaxRAMFraction"    },
 394   { "CMSMarkStackSizeMax",      "MarkStackSizeMax"  },
 395   { "CMSMarkStackSize",         "MarkStackSize"     },
 396   { "G1MarkStackSize",          "MarkStackSize"     },
 397   { "ParallelMarkingThreads",   "ConcGCThreads"     },
 398   { "ParallelCMSThreads",       "ConcGCThreads"     },
 399   { "CreateMinidumpOnCrash",    "CreateCoredumpOnCrash" },
 400   { NULL, NULL}
 401 };
 402 
 403 static AliasedLoggingFlag const aliased_logging_flags[] = {
 404   { "TraceClassResolution", LogLevel::Info, true, LogTag::_classresolve },
 405   { "TraceExceptions", LogLevel::Info, true, LogTag::_exceptions },
 406   { "TraceMonitorInflation", LogLevel::Debug, true, LogTag::_monitorinflation },
 407   { NULL, LogLevel::Off, false, LogTag::__NO_TAG }



 408 };
 409 
 410 // Return true if "v" is less than "other", where "other" may be "undefined".
 411 static bool version_less_than(JDK_Version v, JDK_Version other) {
 412   assert(!v.is_undefined(), "must be defined");
 413   if (!other.is_undefined() && v.compare(other) >= 0) {
 414     return false;
 415   } else {
 416     return true;
 417   }
 418 }
 419 
 420 static bool lookup_special_flag(const char *flag_name, SpecialFlag& flag) {
 421   for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
 422     if ((strcmp(special_jvm_flags[i].name, flag_name) == 0)) {
 423       flag = special_jvm_flags[i];
 424       return true;
 425     }
 426   }
 427   return false;


 920       return real_name;
 921     case 1: {
 922       if (warn) {
 923         char version[256];
 924         since.to_string(version, sizeof(version));
 925         if (real_name != arg) {
 926           warning("Option %s was deprecated in version %s and will likely be removed in a future release. Use option %s instead.",
 927                   arg, version, real_name);
 928         } else {
 929           warning("Option %s was deprecated in version %s and will likely be removed in a future release.",
 930                   arg, version);
 931         }
 932       }
 933       return real_name;
 934     }
 935   }
 936   ShouldNotReachHere();
 937   return NULL;
 938 }
 939 
 940 AliasedLoggingFlag Arguments::catch_logging_aliases(const char* name){
 941   for (size_t i = 0; aliased_logging_flags[i].alias_name != NULL; i++) {
 942     const AliasedLoggingFlag& alf = aliased_logging_flags[i];
 943     if (strcmp(alf.alias_name, name) == 0) {
 944       return alf;




 945     }
 946   }
 947   AliasedLoggingFlag a = {NULL, LogLevel::Off, false, LogTag::__NO_TAG};
 948   return a;
 949 }
 950 
 951 bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
 952 
 953   // range of acceptable characters spelled out for portability reasons
 954 #define NAME_RANGE  "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]"
 955 #define BUFLEN 255
 956   char name[BUFLEN+1];
 957   char dummy;
 958   const char* real_name;
 959   bool warn_if_deprecated = true;
 960   AliasedLoggingFlag alf;
 961 
 962   if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
 963     alf = catch_logging_aliases(name);
 964     if (alf.alias_name != NULL){
 965       LogConfiguration::configure_stdout(LogLevel::Off, alf.exactMatch, alf.tag, LogTag::__NO_TAG);
 966       return true;
 967     }
 968     real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
 969     if (real_name == NULL) {
 970       return false;
 971     }
 972     return set_bool_flag(real_name, false, origin);
 973   }
 974   if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
 975     alf = catch_logging_aliases(name);
 976     if (alf.alias_name != NULL){
 977       LogConfiguration::configure_stdout(alf.level, alf.exactMatch, alf.tag, LogTag::__NO_TAG);
 978       return true;
 979     }
 980     real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
 981     if (real_name == NULL) {
 982       return false;
 983     }
 984     return set_bool_flag(real_name, true, origin);
 985   }
 986 
 987   char punct;
 988   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') {
 989     const char* value = strchr(arg, '=') + 1;
 990     Flag* flag;
 991 
 992     // this scanf pattern matches both strings (handled here) and numbers (handled later))
 993     real_name = handle_aliases_and_deprecation(name, warn_if_deprecated);
 994     if (real_name == NULL) {
 995       return false;
 996     }
 997     flag = Flag::find_flag(real_name);
 998     if (flag != NULL && flag->is_ccstr()) {
 999       if (flag->ccstr_accumulates()) {


2618   }
2619 
2620   if (strcmp(name, _jdwp) == 0) {
2621     return true;
2622   }
2623 
2624   return false;
2625 }
2626 
2627 jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
2628                                        SysClassPath* scp_p,
2629                                        bool* scp_assembly_required_p,
2630                                        Flag::Flags origin) {
2631   // Remaining part of option string
2632   const char* tail;
2633 
2634   // iterate over arguments
2635   for (int index = 0; index < args->nOptions; index++) {
2636     bool is_absolute_path = false;  // for -agentpath vs -agentlib
2637 
2638     const JavaVMOption* option = args->options + index;
2639 
2640     if (!match_option(option, "-Djava.class.path", &tail) &&
2641         !match_option(option, "-Dsun.java.command", &tail) &&
2642         !match_option(option, "-Dsun.java.launcher", &tail)) {
2643 
2644         // add all jvm options to the jvm_args string. This string
2645         // is used later to set the java.vm.args PerfData string constant.
2646         // the -Djava.class.path and the -Dsun.java.command options are
2647         // omitted from jvm_args string as each have their own PerfData
2648         // string constant object.
2649         build_jvm_args(option->optionString);










2650     }
2651 
2652     // -verbose:[class/gc/jni]
2653     if (match_option(option, "-verbose", &tail)) {
2654       if (!strcmp(tail, ":class") || !strcmp(tail, "")) {
2655         if (FLAG_SET_CMDLINE(bool, TraceClassLoading, true) != Flag::SUCCESS) {
2656           return JNI_EINVAL;
2657         }
2658         if (FLAG_SET_CMDLINE(bool, TraceClassUnloading, true) != Flag::SUCCESS) {
2659           return JNI_EINVAL;
2660         }
2661       } else if (!strcmp(tail, ":gc")) {
2662         // LogConfiguration_lock is not set up yet, but this code is executed by a single thread
2663         bool ret = LogConfiguration::parse_log_arguments("stdout", "gc", NULL, NULL, NULL);
2664         if (!ret) {
2665           return JNI_EINVAL;
2666         }
2667       } else if (!strcmp(tail, ":jni")) {
2668         if (FLAG_SET_CMDLINE(bool, PrintJNIResolving, true) != Flag::SUCCESS) {
2669           return JNI_EINVAL;


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