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