761 struct dirent *entry; 762 char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtArguments); 763 while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) { 764 const char* name = entry->d_name; 765 const char* ext = name + strlen(name) - 4; 766 bool isJarOrZip = ext > name && 767 (os::file_name_strcmp(ext, ".jar") == 0 || 768 os::file_name_strcmp(ext, ".zip") == 0); 769 if (isJarOrZip) { 770 char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name), mtArguments); 771 sprintf(jarpath, "%s%s%s", directory, dir_sep, name); 772 path = add_to_path(path, jarpath, false); 773 FREE_C_HEAP_ARRAY(char, jarpath); 774 } 775 } 776 FREE_C_HEAP_ARRAY(char, dbuf); 777 os::closedir(dir); 778 return path; 779 } 780 781 // Parses a memory size specification string. 782 static bool atomull(const char *s, julong* result) { 783 julong n = 0; 784 int args_read = 0; 785 bool is_hex = false; 786 // Skip leading 0[xX] for hexadecimal 787 if (*s =='0' && (*(s+1) == 'x' || *(s+1) == 'X')) { 788 s += 2; 789 is_hex = true; 790 args_read = sscanf(s, JULONG_FORMAT_X, &n); 791 } else { 792 args_read = sscanf(s, JULONG_FORMAT, &n); 793 } 794 if (args_read != 1) { 795 return false; 796 } 797 while (*s != '\0' && (isdigit(*s) || (is_hex && isxdigit(*s)))) { 798 s++; 799 } 800 // 4705540: illegal if more characters are found after the first non-digit 801 if (strlen(s) > 1) { 802 return false; 868 return false; 869 } 870 871 if (CommandLineFlags::doubleAtPut(name, &v, origin) == Flag::SUCCESS) { 872 return true; 873 } 874 return false; 875 } 876 877 static bool set_numeric_flag(const char* name, char* value, Flag::Flags origin) { 878 julong v; 879 int int_v; 880 intx intx_v; 881 bool is_neg = false; 882 Flag* result = Flag::find_flag(name, strlen(name)); 883 884 if (result == NULL) { 885 return false; 886 } 887 888 // Check the sign first since atomull() parses only unsigned values. 889 if (*value == '-') { 890 if (!result->is_intx() && !result->is_int()) { 891 return false; 892 } 893 value++; 894 is_neg = true; 895 } 896 if (!atomull(value, &v)) { 897 return false; 898 } 899 if (result->is_int()) { 900 int_v = (int) v; 901 if (is_neg) { 902 int_v = -int_v; 903 } 904 return CommandLineFlags::intAtPut(result, &int_v, origin) == Flag::SUCCESS; 905 } else if (result->is_uint()) { 906 uint uint_v = (uint) v; 907 return CommandLineFlags::uintAtPut(result, &uint_v, origin) == Flag::SUCCESS; 908 } else if (result->is_intx()) { 909 intx_v = (intx) v; 910 if (is_neg) { 911 intx_v = -intx_v; 912 } 913 return CommandLineFlags::intxAtPut(result, &intx_v, origin) == Flag::SUCCESS; 914 } else if (result->is_uintx()) { 915 uintx uintx_v = (uintx) v; 916 return CommandLineFlags::uintxAtPut(result, &uintx_v, origin) == Flag::SUCCESS; 2676 } else { 2677 jio_fprintf(defaultStream::error_stream(), 2678 "Unrecognized %s%soption: %s\n", option_type, spacer, 2679 option->optionString); 2680 return true; 2681 } 2682 } 2683 2684 static const char* user_assertion_options[] = { 2685 "-da", "-ea", "-disableassertions", "-enableassertions", 0 2686 }; 2687 2688 static const char* system_assertion_options[] = { 2689 "-dsa", "-esa", "-disablesystemassertions", "-enablesystemassertions", 0 2690 }; 2691 2692 bool Arguments::parse_uintx(const char* value, 2693 uintx* uintx_arg, 2694 uintx min_size) { 2695 2696 // Check the sign first since atomull() parses only unsigned values. 2697 bool value_is_positive = !(*value == '-'); 2698 2699 if (value_is_positive) { 2700 julong n; 2701 bool good_return = atomull(value, &n); 2702 if (good_return) { 2703 bool above_minimum = n >= min_size; 2704 bool value_is_too_large = n > max_uintx; 2705 2706 if (above_minimum && !value_is_too_large) { 2707 *uintx_arg = n; 2708 return true; 2709 } 2710 } 2711 } 2712 return false; 2713 } 2714 2715 Arguments::ArgsRange Arguments::parse_memory_size(const char* s, 2716 julong* long_arg, 2717 julong min_size) { 2718 if (!atomull(s, long_arg)) return arg_unreadable; 2719 return check_memory_size(*long_arg, min_size); 2720 } 2721 2722 // Parse JavaVMInitArgs structure 2723 2724 jint Arguments::parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args, 2725 const JavaVMInitArgs *java_options_args, 2726 const JavaVMInitArgs *cmd_line_args) { 2727 // For components of the system classpath. 2728 ArgumentBootClassPath bcp(Arguments::get_sysclasspath()); 2729 bool bcp_assembly_required = false; 2730 2731 // Save default settings for some mode flags 2732 Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods; 2733 Arguments::_UseOnStackReplacement = UseOnStackReplacement; 2734 Arguments::_ClipInlining = ClipInlining; 2735 Arguments::_BackgroundCompilation = BackgroundCompilation; 2736 if (TieredCompilation) { 2737 Arguments::_Tier3InvokeNotifyFreqLog = Tier3InvokeNotifyFreqLog; 2738 Arguments::_Tier4InvocationThreshold = Tier4InvocationThreshold; | 761 struct dirent *entry; 762 char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtArguments); 763 while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) { 764 const char* name = entry->d_name; 765 const char* ext = name + strlen(name) - 4; 766 bool isJarOrZip = ext > name && 767 (os::file_name_strcmp(ext, ".jar") == 0 || 768 os::file_name_strcmp(ext, ".zip") == 0); 769 if (isJarOrZip) { 770 char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name), mtArguments); 771 sprintf(jarpath, "%s%s%s", directory, dir_sep, name); 772 path = add_to_path(path, jarpath, false); 773 FREE_C_HEAP_ARRAY(char, jarpath); 774 } 775 } 776 FREE_C_HEAP_ARRAY(char, dbuf); 777 os::closedir(dir); 778 return path; 779 } 780 781 // Parses a size specification string. 782 bool Arguments::atojulong(const char *s, julong* result) { 783 julong n = 0; 784 int args_read = 0; 785 bool is_hex = false; 786 // Skip leading 0[xX] for hexadecimal 787 if (*s =='0' && (*(s+1) == 'x' || *(s+1) == 'X')) { 788 s += 2; 789 is_hex = true; 790 args_read = sscanf(s, JULONG_FORMAT_X, &n); 791 } else { 792 args_read = sscanf(s, JULONG_FORMAT, &n); 793 } 794 if (args_read != 1) { 795 return false; 796 } 797 while (*s != '\0' && (isdigit(*s) || (is_hex && isxdigit(*s)))) { 798 s++; 799 } 800 // 4705540: illegal if more characters are found after the first non-digit 801 if (strlen(s) > 1) { 802 return false; 868 return false; 869 } 870 871 if (CommandLineFlags::doubleAtPut(name, &v, origin) == Flag::SUCCESS) { 872 return true; 873 } 874 return false; 875 } 876 877 static bool set_numeric_flag(const char* name, char* value, Flag::Flags origin) { 878 julong v; 879 int int_v; 880 intx intx_v; 881 bool is_neg = false; 882 Flag* result = Flag::find_flag(name, strlen(name)); 883 884 if (result == NULL) { 885 return false; 886 } 887 888 // Check the sign first since atojulong() parses only unsigned values. 889 if (*value == '-') { 890 if (!result->is_intx() && !result->is_int()) { 891 return false; 892 } 893 value++; 894 is_neg = true; 895 } 896 if (!Arguments::atojulong(value, &v)) { 897 return false; 898 } 899 if (result->is_int()) { 900 int_v = (int) v; 901 if (is_neg) { 902 int_v = -int_v; 903 } 904 return CommandLineFlags::intAtPut(result, &int_v, origin) == Flag::SUCCESS; 905 } else if (result->is_uint()) { 906 uint uint_v = (uint) v; 907 return CommandLineFlags::uintAtPut(result, &uint_v, origin) == Flag::SUCCESS; 908 } else if (result->is_intx()) { 909 intx_v = (intx) v; 910 if (is_neg) { 911 intx_v = -intx_v; 912 } 913 return CommandLineFlags::intxAtPut(result, &intx_v, origin) == Flag::SUCCESS; 914 } else if (result->is_uintx()) { 915 uintx uintx_v = (uintx) v; 916 return CommandLineFlags::uintxAtPut(result, &uintx_v, origin) == Flag::SUCCESS; 2676 } else { 2677 jio_fprintf(defaultStream::error_stream(), 2678 "Unrecognized %s%soption: %s\n", option_type, spacer, 2679 option->optionString); 2680 return true; 2681 } 2682 } 2683 2684 static const char* user_assertion_options[] = { 2685 "-da", "-ea", "-disableassertions", "-enableassertions", 0 2686 }; 2687 2688 static const char* system_assertion_options[] = { 2689 "-dsa", "-esa", "-disablesystemassertions", "-enablesystemassertions", 0 2690 }; 2691 2692 bool Arguments::parse_uintx(const char* value, 2693 uintx* uintx_arg, 2694 uintx min_size) { 2695 2696 // Check the sign first since atojulong() parses only unsigned values. 2697 bool value_is_positive = !(*value == '-'); 2698 2699 if (value_is_positive) { 2700 julong n; 2701 bool good_return = atojulong(value, &n); 2702 if (good_return) { 2703 bool above_minimum = n >= min_size; 2704 bool value_is_too_large = n > max_uintx; 2705 2706 if (above_minimum && !value_is_too_large) { 2707 *uintx_arg = n; 2708 return true; 2709 } 2710 } 2711 } 2712 return false; 2713 } 2714 2715 Arguments::ArgsRange Arguments::parse_memory_size(const char* s, 2716 julong* long_arg, 2717 julong min_size) { 2718 if (!atojulong(s, long_arg)) return arg_unreadable; 2719 return check_memory_size(*long_arg, min_size); 2720 } 2721 2722 // Parse JavaVMInitArgs structure 2723 2724 jint Arguments::parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args, 2725 const JavaVMInitArgs *java_options_args, 2726 const JavaVMInitArgs *cmd_line_args) { 2727 // For components of the system classpath. 2728 ArgumentBootClassPath bcp(Arguments::get_sysclasspath()); 2729 bool bcp_assembly_required = false; 2730 2731 // Save default settings for some mode flags 2732 Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods; 2733 Arguments::_UseOnStackReplacement = UseOnStackReplacement; 2734 Arguments::_ClipInlining = ClipInlining; 2735 Arguments::_BackgroundCompilation = BackgroundCompilation; 2736 if (TieredCompilation) { 2737 Arguments::_Tier3InvokeNotifyFreqLog = Tier3InvokeNotifyFreqLog; 2738 Arguments::_Tier4InvocationThreshold = Tier4InvocationThreshold; |