769 char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal);
770 while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
771 const char* name = entry->d_name;
772 const char* ext = name + strlen(name) - 4;
773 bool isJarOrZip = ext > name &&
774 (os::file_name_strcmp(ext, ".jar") == 0 ||
775 os::file_name_strcmp(ext, ".zip") == 0);
776 if (isJarOrZip) {
777 char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name), mtInternal);
778 sprintf(jarpath, "%s%s%s", directory, dir_sep, name);
779 path = add_to_path(path, jarpath, false);
780 FREE_C_HEAP_ARRAY(char, jarpath);
781 }
782 }
783 FREE_C_HEAP_ARRAY(char, dbuf);
784 os::closedir(dir);
785 return path;
786 }
787
788 // Parses a memory size specification string.
789 static bool atomull(const char *s, julong* result) {
790 julong n = 0;
791 int args_read = 0;
792 bool is_hex = false;
793 // Skip leading 0[xX] for hexadecimal
794 if (*s =='0' && (*(s+1) == 'x' || *(s+1) == 'X')) {
795 s += 2;
796 is_hex = true;
797 args_read = sscanf(s, JULONG_FORMAT_X, &n);
798 } else {
799 args_read = sscanf(s, JULONG_FORMAT, &n);
800 }
801 if (args_read != 1) {
802 return false;
803 }
804 while (*s != '\0' && (isdigit(*s) || (is_hex && isxdigit(*s)))) {
805 s++;
806 }
807 // 4705540: illegal if more characters are found after the first non-digit
808 if (strlen(s) > 1) {
809 return false;
883
884 static bool set_numeric_flag(const char* name, char* value, Flag::Flags origin) {
885 julong v;
886 int int_v;
887 intx intx_v;
888 bool is_neg = false;
889 Flag* result = Flag::find_flag(name, strlen(name));
890
891 if (result == NULL) {
892 return false;
893 }
894
895 // Check the sign first since atomull() parses only unsigned values.
896 if (*value == '-') {
897 if (!result->is_intx() && !result->is_int()) {
898 return false;
899 }
900 value++;
901 is_neg = true;
902 }
903 if (!atomull(value, &v)) {
904 return false;
905 }
906 if (result->is_int()) {
907 int_v = (int) v;
908 if (is_neg) {
909 int_v = -int_v;
910 }
911 return CommandLineFlags::intAtPut(result, &int_v, origin) == Flag::SUCCESS;
912 } else if (result->is_uint()) {
913 uint uint_v = (uint) v;
914 return CommandLineFlags::uintAtPut(result, &uint_v, origin) == Flag::SUCCESS;
915 } else if (result->is_intx()) {
916 intx_v = (intx) v;
917 if (is_neg) {
918 intx_v = -intx_v;
919 }
920 return CommandLineFlags::intxAtPut(result, &intx_v, origin) == Flag::SUCCESS;
921 } else if (result->is_uintx()) {
922 uintx uintx_v = (uintx) v;
923 return CommandLineFlags::uintxAtPut(result, &uintx_v, origin) == Flag::SUCCESS;
2623 }
2624 }
2625
2626 static const char* user_assertion_options[] = {
2627 "-da", "-ea", "-disableassertions", "-enableassertions", 0
2628 };
2629
2630 static const char* system_assertion_options[] = {
2631 "-dsa", "-esa", "-disablesystemassertions", "-enablesystemassertions", 0
2632 };
2633
2634 bool Arguments::parse_uintx(const char* value,
2635 uintx* uintx_arg,
2636 uintx min_size) {
2637
2638 // Check the sign first since atomull() parses only unsigned values.
2639 bool value_is_positive = !(*value == '-');
2640
2641 if (value_is_positive) {
2642 julong n;
2643 bool good_return = atomull(value, &n);
2644 if (good_return) {
2645 bool above_minimum = n >= min_size;
2646 bool value_is_too_large = n > max_uintx;
2647
2648 if (above_minimum && !value_is_too_large) {
2649 *uintx_arg = n;
2650 return true;
2651 }
2652 }
2653 }
2654 return false;
2655 }
2656
2657 Arguments::ArgsRange Arguments::parse_memory_size(const char* s,
2658 julong* long_arg,
2659 julong min_size) {
2660 if (!atomull(s, long_arg)) return arg_unreadable;
2661 return check_memory_size(*long_arg, min_size);
2662 }
2663
2664 // Parse JavaVMInitArgs structure
2665
2666 jint Arguments::parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args,
2667 const JavaVMInitArgs *java_options_args,
2668 const JavaVMInitArgs *cmd_line_args) {
2669 // For components of the system classpath.
2670 ArgumentBootClassPath bcp(Arguments::get_sysclasspath());
2671 bool bcp_assembly_required = false;
2672
2673 // Save default settings for some mode flags
2674 Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
2675 Arguments::_UseOnStackReplacement = UseOnStackReplacement;
2676 Arguments::_ClipInlining = ClipInlining;
2677 Arguments::_BackgroundCompilation = BackgroundCompilation;
2678 if (TieredCompilation) {
2679 Arguments::_Tier3InvokeNotifyFreqLog = Tier3InvokeNotifyFreqLog;
2680 Arguments::_Tier4InvocationThreshold = Tier4InvocationThreshold;
|
769 char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(directory), mtInternal);
770 while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) {
771 const char* name = entry->d_name;
772 const char* ext = name + strlen(name) - 4;
773 bool isJarOrZip = ext > name &&
774 (os::file_name_strcmp(ext, ".jar") == 0 ||
775 os::file_name_strcmp(ext, ".zip") == 0);
776 if (isJarOrZip) {
777 char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name), mtInternal);
778 sprintf(jarpath, "%s%s%s", directory, dir_sep, name);
779 path = add_to_path(path, jarpath, false);
780 FREE_C_HEAP_ARRAY(char, jarpath);
781 }
782 }
783 FREE_C_HEAP_ARRAY(char, dbuf);
784 os::closedir(dir);
785 return path;
786 }
787
788 // Parses a memory size specification string.
789 bool Arguments::atomull(const char *s, julong* result) {
790 julong n = 0;
791 int args_read = 0;
792 bool is_hex = false;
793 // Skip leading 0[xX] for hexadecimal
794 if (*s =='0' && (*(s+1) == 'x' || *(s+1) == 'X')) {
795 s += 2;
796 is_hex = true;
797 args_read = sscanf(s, JULONG_FORMAT_X, &n);
798 } else {
799 args_read = sscanf(s, JULONG_FORMAT, &n);
800 }
801 if (args_read != 1) {
802 return false;
803 }
804 while (*s != '\0' && (isdigit(*s) || (is_hex && isxdigit(*s)))) {
805 s++;
806 }
807 // 4705540: illegal if more characters are found after the first non-digit
808 if (strlen(s) > 1) {
809 return false;
883
884 static bool set_numeric_flag(const char* name, char* value, Flag::Flags origin) {
885 julong v;
886 int int_v;
887 intx intx_v;
888 bool is_neg = false;
889 Flag* result = Flag::find_flag(name, strlen(name));
890
891 if (result == NULL) {
892 return false;
893 }
894
895 // Check the sign first since atomull() parses only unsigned values.
896 if (*value == '-') {
897 if (!result->is_intx() && !result->is_int()) {
898 return false;
899 }
900 value++;
901 is_neg = true;
902 }
903 if (!Arguments::atomull(value, &v)) {
904 return false;
905 }
906 if (result->is_int()) {
907 int_v = (int) v;
908 if (is_neg) {
909 int_v = -int_v;
910 }
911 return CommandLineFlags::intAtPut(result, &int_v, origin) == Flag::SUCCESS;
912 } else if (result->is_uint()) {
913 uint uint_v = (uint) v;
914 return CommandLineFlags::uintAtPut(result, &uint_v, origin) == Flag::SUCCESS;
915 } else if (result->is_intx()) {
916 intx_v = (intx) v;
917 if (is_neg) {
918 intx_v = -intx_v;
919 }
920 return CommandLineFlags::intxAtPut(result, &intx_v, origin) == Flag::SUCCESS;
921 } else if (result->is_uintx()) {
922 uintx uintx_v = (uintx) v;
923 return CommandLineFlags::uintxAtPut(result, &uintx_v, origin) == Flag::SUCCESS;
2623 }
2624 }
2625
2626 static const char* user_assertion_options[] = {
2627 "-da", "-ea", "-disableassertions", "-enableassertions", 0
2628 };
2629
2630 static const char* system_assertion_options[] = {
2631 "-dsa", "-esa", "-disablesystemassertions", "-enablesystemassertions", 0
2632 };
2633
2634 bool Arguments::parse_uintx(const char* value,
2635 uintx* uintx_arg,
2636 uintx min_size) {
2637
2638 // Check the sign first since atomull() parses only unsigned values.
2639 bool value_is_positive = !(*value == '-');
2640
2641 if (value_is_positive) {
2642 julong n;
2643 bool good_return = Arguments::atomull(value, &n);
2644 if (good_return) {
2645 bool above_minimum = n >= min_size;
2646 bool value_is_too_large = n > max_uintx;
2647
2648 if (above_minimum && !value_is_too_large) {
2649 *uintx_arg = n;
2650 return true;
2651 }
2652 }
2653 }
2654 return false;
2655 }
2656
2657 Arguments::ArgsRange Arguments::parse_memory_size(const char* s,
2658 julong* long_arg,
2659 julong min_size) {
2660 if (!Arguments::atomull(s, long_arg)) return arg_unreadable;
2661 return check_memory_size(*long_arg, min_size);
2662 }
2663
2664 // Parse JavaVMInitArgs structure
2665
2666 jint Arguments::parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args,
2667 const JavaVMInitArgs *java_options_args,
2668 const JavaVMInitArgs *cmd_line_args) {
2669 // For components of the system classpath.
2670 ArgumentBootClassPath bcp(Arguments::get_sysclasspath());
2671 bool bcp_assembly_required = false;
2672
2673 // Save default settings for some mode flags
2674 Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
2675 Arguments::_UseOnStackReplacement = UseOnStackReplacement;
2676 Arguments::_ClipInlining = ClipInlining;
2677 Arguments::_BackgroundCompilation = BackgroundCompilation;
2678 if (TieredCompilation) {
2679 Arguments::_Tier3InvokeNotifyFreqLog = Tier3InvokeNotifyFreqLog;
2680 Arguments::_Tier4InvocationThreshold = Tier4InvocationThreshold;
|