824 if (_num_jvm_flags > 0) { 825 for (int i=0; i < _num_jvm_flags; i++) { 826 st->print("%s ", _jvm_flags_array[i]); 827 } 828 } 829 } 830 831 void Arguments::print_jvm_args_on(outputStream* st) { 832 if (_num_jvm_args > 0) { 833 for (int i=0; i < _num_jvm_args; i++) { 834 st->print("%s ", _jvm_args_array[i]); 835 } 836 } 837 } 838 839 bool Arguments::process_argument(const char* arg, 840 jboolean ignore_unrecognized, Flag::Flags origin) { 841 842 JDK_Version since = JDK_Version(); 843 844 if (parse_argument(arg, origin) || ignore_unrecognized) { 845 return true; 846 } 847 848 // Determine if the flag has '+', '-', or '=' characters. 849 bool has_plus_minus = (*arg == '+' || *arg == '-'); 850 const char* const argname = has_plus_minus ? arg + 1 : arg; 851 852 size_t arg_len; 853 const char* equal_sign = strchr(argname, '='); 854 if (equal_sign == NULL) { 855 arg_len = strlen(argname); 856 } else { 857 arg_len = equal_sign - argname; 858 } 859 860 // Only make the obsolete check for valid arguments. 861 if (arg_len <= BUFLEN) { 862 // Construct a string which consists only of the argument name without '+', '-', or '='. 863 char stripped_argname[BUFLEN+1]; 864 strncpy(stripped_argname, argname, arg_len); 865 stripped_argname[arg_len] = '\0'; // strncpy may not null terminate. 866 867 if (is_newly_obsolete(stripped_argname, &since)) { 868 char version[256]; 869 since.to_string(version, sizeof(version)); 870 warning("ignoring option %s; support was removed in %s", stripped_argname, version); 871 return true; 872 } 873 } 874 875 // For locked flags, report a custom error message if available. 876 // Otherwise, report the standard unrecognized VM option. 877 Flag* found_flag = Flag::find_flag((const char*)argname, arg_len, true, true); 878 if (found_flag != NULL) { 879 char locked_message_buf[BUFLEN]; 880 found_flag->get_locked_message(locked_message_buf, BUFLEN); 881 if (strlen(locked_message_buf) == 0) { 882 if (found_flag->is_bool() && !has_plus_minus) { 883 jio_fprintf(defaultStream::error_stream(), 884 "Missing +/- setting for VM option '%s'\n", argname); 885 } else if (!found_flag->is_bool() && has_plus_minus) { 886 jio_fprintf(defaultStream::error_stream(), 887 "Unexpected +/- setting in VM option '%s'\n", argname); 888 } else { 889 jio_fprintf(defaultStream::error_stream(), 890 "Improperly specified VM option '%s'\n", argname); 891 } 892 } else { 893 jio_fprintf(defaultStream::error_stream(), "%s", locked_message_buf); 894 } 895 } else { 896 jio_fprintf(defaultStream::error_stream(), 897 "Unrecognized VM option '%s'\n", argname); 898 Flag* fuzzy_matched = Flag::fuzzy_match((const char*)argname, arg_len, true); 899 if (fuzzy_matched != NULL) { 900 jio_fprintf(defaultStream::error_stream(), 901 "Did you mean '%s%s%s'? ", 902 (fuzzy_matched->is_bool()) ? "(+/-)" : "", 903 fuzzy_matched->_name, 904 (fuzzy_matched->is_bool()) ? "" : "=<value>"); 905 } 906 } 907 908 // allow for commandline "commenting out" options like -XX:#+Verbose 909 return arg[0] == '#'; 910 } 911 912 bool Arguments::process_settings_file(const char* file_name, bool should_exist, jboolean ignore_unrecognized) { 913 FILE* stream = fopen(file_name, "rb"); 914 if (stream == NULL) { 915 if (should_exist) { | 824 if (_num_jvm_flags > 0) { 825 for (int i=0; i < _num_jvm_flags; i++) { 826 st->print("%s ", _jvm_flags_array[i]); 827 } 828 } 829 } 830 831 void Arguments::print_jvm_args_on(outputStream* st) { 832 if (_num_jvm_args > 0) { 833 for (int i=0; i < _num_jvm_args; i++) { 834 st->print("%s ", _jvm_args_array[i]); 835 } 836 } 837 } 838 839 bool Arguments::process_argument(const char* arg, 840 jboolean ignore_unrecognized, Flag::Flags origin) { 841 842 JDK_Version since = JDK_Version(); 843 844 if (parse_argument(arg, origin)) { 845 return true; 846 } 847 848 // Determine if the flag has '+', '-', or '=' characters. 849 bool has_plus_minus = (*arg == '+' || *arg == '-'); 850 const char* const argname = has_plus_minus ? arg + 1 : arg; 851 852 size_t arg_len; 853 const char* equal_sign = strchr(argname, '='); 854 if (equal_sign == NULL) { 855 arg_len = strlen(argname); 856 } else { 857 arg_len = equal_sign - argname; 858 } 859 860 // Only make the obsolete check for valid arguments. 861 if (arg_len <= BUFLEN) { 862 // Construct a string which consists only of the argument name without '+', '-', or '='. 863 char stripped_argname[BUFLEN+1]; 864 strncpy(stripped_argname, argname, arg_len); 865 stripped_argname[arg_len] = '\0'; // strncpy may not null terminate. 866 867 if (is_newly_obsolete(stripped_argname, &since)) { 868 char version[256]; 869 since.to_string(version, sizeof(version)); 870 warning("ignoring option %s; support was removed in %s", stripped_argname, version); 871 return true; 872 } 873 } 874 875 // For locked flags, report a custom error message if available. 876 // Otherwise, report the standard unrecognized VM option. 877 Flag* found_flag = Flag::find_flag((const char*)argname, arg_len, true, true); 878 if (found_flag != NULL) { 879 char locked_message_buf[BUFLEN]; 880 Flag::MsgType msg_type = found_flag->get_locked_message(locked_message_buf, BUFLEN); 881 if (strlen(locked_message_buf) == 0) { 882 if (found_flag->is_bool() && !has_plus_minus) { 883 jio_fprintf(defaultStream::error_stream(), 884 "Missing +/- setting for VM option '%s'\n", argname); 885 } else if (!found_flag->is_bool() && has_plus_minus) { 886 jio_fprintf(defaultStream::error_stream(), 887 "Unexpected +/- setting in VM option '%s'\n", argname); 888 } else { 889 jio_fprintf(defaultStream::error_stream(), 890 "Improperly specified VM option '%s'\n", argname); 891 } 892 } else { 893 #ifdef PRODUCT 894 bool mismatched = ((msg_type == Flag::NOTPRODUCT_FLAG_BUT_PRODUCT_BUILD) || 895 (msg_type == Flag::DEVELOPER_FLAG_BUT_PRODUCT_BUILD)); 896 if (ignore_unrecognized && mismatched) { 897 return true; 898 } 899 #endif 900 jio_fprintf(defaultStream::error_stream(), "%s", locked_message_buf); 901 } 902 } else { 903 if (ignore_unrecognized) { 904 return true; 905 } 906 jio_fprintf(defaultStream::error_stream(), 907 "Unrecognized VM option '%s'\n", argname); 908 Flag* fuzzy_matched = Flag::fuzzy_match((const char*)argname, arg_len, true); 909 if (fuzzy_matched != NULL) { 910 jio_fprintf(defaultStream::error_stream(), 911 "Did you mean '%s%s%s'? ", 912 (fuzzy_matched->is_bool()) ? "(+/-)" : "", 913 fuzzy_matched->_name, 914 (fuzzy_matched->is_bool()) ? "" : "=<value>"); 915 } 916 } 917 918 // allow for commandline "commenting out" options like -XX:#+Verbose 919 return arg[0] == '#'; 920 } 921 922 bool Arguments::process_settings_file(const char* file_name, bool should_exist, jboolean ignore_unrecognized) { 923 FILE* stream = fopen(file_name, "rb"); 924 if (stream == NULL) { 925 if (should_exist) { |