608 }
609
610 // Describe an argument out of range error
611 void Arguments::describe_range_error(ArgsRange errcode) {
612 switch(errcode) {
613 case arg_too_big:
614 jio_fprintf(defaultStream::error_stream(),
615 "The specified size exceeds the maximum "
616 "representable size.\n");
617 break;
618 case arg_too_small:
619 case arg_unreadable:
620 case arg_in_range:
621 // do nothing for now
622 break;
623 default:
624 ShouldNotReachHere();
625 }
626 }
627
628 static bool set_bool_flag(char* name, bool value, FlagValueOrigin origin) {
629 return CommandLineFlags::boolAtPut(name, &value, origin);
630 }
631
632 static bool set_fp_numeric_flag(char* name, char* value, FlagValueOrigin origin) {
633 double v;
634 if (sscanf(value, "%lf", &v) != 1) {
635 return false;
636 }
637
638 if (CommandLineFlags::doubleAtPut(name, &v, origin)) {
639 return true;
640 }
641 return false;
642 }
643
644 static bool set_numeric_flag(char* name, char* value, FlagValueOrigin origin) {
645 julong v;
646 intx intx_v;
647 bool is_neg = false;
648 // Check the sign first since atomull() parses only unsigned values.
649 if (*value == '-') {
650 if (!CommandLineFlags::intxAt(name, &intx_v)) {
651 return false;
652 }
653 value++;
654 is_neg = true;
655 }
656 if (!atomull(value, &v)) {
657 return false;
658 }
659 intx_v = (intx) v;
660 if (is_neg) {
661 intx_v = -intx_v;
662 }
663 if (CommandLineFlags::intxAtPut(name, &intx_v, origin)) {
664 return true;
665 }
666 uintx uintx_v = (uintx) v;
667 if (!is_neg && CommandLineFlags::uintxAtPut(name, &uintx_v, origin)) {
668 return true;
669 }
670 uint64_t uint64_t_v = (uint64_t) v;
671 if (!is_neg && CommandLineFlags::uint64_tAtPut(name, &uint64_t_v, origin)) {
672 return true;
673 }
674 return false;
675 }
676
677 static bool set_string_flag(char* name, const char* value, FlagValueOrigin origin) {
678 if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false;
679 // Contract: CommandLineFlags always returns a pointer that needs freeing.
680 FREE_C_HEAP_ARRAY(char, value, mtInternal);
681 return true;
682 }
683
684 static bool append_to_string_flag(char* name, const char* new_value, FlagValueOrigin origin) {
685 const char* old_value = "";
686 if (!CommandLineFlags::ccstrAt(name, &old_value)) return false;
687 size_t old_len = old_value != NULL ? strlen(old_value) : 0;
688 size_t new_len = strlen(new_value);
689 const char* value;
690 char* free_this_too = NULL;
691 if (old_len == 0) {
692 value = new_value;
693 } else if (new_len == 0) {
694 value = old_value;
695 } else {
696 char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1, mtInternal);
697 // each new setting adds another LINE to the switch:
698 sprintf(buf, "%s\n%s", old_value, new_value);
699 value = buf;
700 free_this_too = buf;
701 }
702 (void) CommandLineFlags::ccstrAtPut(name, &value, origin);
703 // CommandLineFlags always returns a pointer that needs freeing.
704 FREE_C_HEAP_ARRAY(char, value, mtInternal);
705 if (free_this_too != NULL) {
706 // CommandLineFlags made its own copy, so I must delete my own temp. buffer.
707 FREE_C_HEAP_ARRAY(char, free_this_too, mtInternal);
708 }
709 return true;
710 }
711
712 bool Arguments::parse_argument(const char* arg, FlagValueOrigin origin) {
713
714 // range of acceptable characters spelled out for portability reasons
715 #define NAME_RANGE "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]"
716 #define BUFLEN 255
717 char name[BUFLEN+1];
718 char dummy;
719
720 if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
721 return set_bool_flag(name, false, origin);
722 }
723 if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
724 return set_bool_flag(name, true, origin);
725 }
726
727 char punct;
728 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') {
729 const char* value = strchr(arg, '=') + 1;
730 Flag* flag = Flag::find_flag(name, strlen(name));
731 if (flag != NULL && flag->is_ccstr()) {
732 if (flag->ccstr_accumulates()) {
833
834 void Arguments::print_jvm_flags_on(outputStream* st) {
835 if (_num_jvm_flags > 0) {
836 for (int i=0; i < _num_jvm_flags; i++) {
837 st->print("%s ", _jvm_flags_array[i]);
838 }
839 st->print_cr("");
840 }
841 }
842
843 void Arguments::print_jvm_args_on(outputStream* st) {
844 if (_num_jvm_args > 0) {
845 for (int i=0; i < _num_jvm_args; i++) {
846 st->print("%s ", _jvm_args_array[i]);
847 }
848 st->print_cr("");
849 }
850 }
851
852 bool Arguments::process_argument(const char* arg,
853 jboolean ignore_unrecognized, FlagValueOrigin origin) {
854
855 JDK_Version since = JDK_Version();
856
857 if (parse_argument(arg, origin) || ignore_unrecognized) {
858 return true;
859 }
860
861 bool has_plus_minus = (*arg == '+' || *arg == '-');
862 const char* const argname = has_plus_minus ? arg + 1 : arg;
863 if (is_newly_obsolete(arg, &since)) {
864 char version[256];
865 since.to_string(version, sizeof(version));
866 warning("ignoring option %s; support was removed in %s", argname, version);
867 return true;
868 }
869
870 // For locked flags, report a custom error message if available.
871 // Otherwise, report the standard unrecognized VM option.
872
873 size_t arg_len;
887 jio_fprintf(defaultStream::error_stream(),
888 "Missing +/- setting for VM option '%s'\n", argname);
889 } else if (!found_flag->is_bool() && has_plus_minus) {
890 jio_fprintf(defaultStream::error_stream(),
891 "Unexpected +/- setting in VM option '%s'\n", argname);
892 } else {
893 jio_fprintf(defaultStream::error_stream(),
894 "Improperly specified VM option '%s'\n", argname);
895 }
896 } else {
897 jio_fprintf(defaultStream::error_stream(), "%s", locked_message_buf);
898 }
899 } else {
900 jio_fprintf(defaultStream::error_stream(),
901 "Unrecognized VM option '%s'\n", argname);
902 Flag* fuzzy_matched = Flag::fuzzy_match((const char*)argname, arg_len, true);
903 if (fuzzy_matched != NULL) {
904 jio_fprintf(defaultStream::error_stream(),
905 "Did you mean '%s%s%s'?\n",
906 (fuzzy_matched->is_bool()) ? "(+/-)" : "",
907 fuzzy_matched->name,
908 (fuzzy_matched->is_bool()) ? "" : "=<value>");
909 }
910 }
911
912 // allow for commandline "commenting out" options like -XX:#+Verbose
913 return arg[0] == '#';
914 }
915
916 bool Arguments::process_settings_file(const char* file_name, bool should_exist, jboolean ignore_unrecognized) {
917 FILE* stream = fopen(file_name, "rb");
918 if (stream == NULL) {
919 if (should_exist) {
920 jio_fprintf(defaultStream::error_stream(),
921 "Could not open settings file %s\n", file_name);
922 return false;
923 } else {
924 return true;
925 }
926 }
927
935 bool result = true;
936
937 int c = getc(stream);
938 while(c != EOF && pos < (int)(sizeof(token)-1)) {
939 if (in_white_space) {
940 if (in_comment) {
941 if (c == '\n') in_comment = false;
942 } else {
943 if (c == '#') in_comment = true;
944 else if (!isspace(c)) {
945 in_white_space = false;
946 token[pos++] = c;
947 }
948 }
949 } else {
950 if (c == '\n' || (!in_quote && isspace(c))) {
951 // token ends at newline, or at unquoted whitespace
952 // this allows a way to include spaces in string-valued options
953 token[pos] = '\0';
954 logOption(token);
955 result &= process_argument(token, ignore_unrecognized, CONFIG_FILE);
956 build_jvm_flags(token);
957 pos = 0;
958 in_white_space = true;
959 in_quote = false;
960 } else if (!in_quote && (c == '\'' || c == '"')) {
961 in_quote = true;
962 quote_c = c;
963 } else if (in_quote && (c == quote_c)) {
964 in_quote = false;
965 } else {
966 token[pos++] = c;
967 }
968 }
969 c = getc(stream);
970 }
971 if (pos > 0) {
972 token[pos] = '\0';
973 result &= process_argument(token, ignore_unrecognized, CONFIG_FILE);
974 build_jvm_flags(token);
975 }
976 fclose(stream);
977 return result;
978 }
979
980 //=============================================================================================================
981 // Parsing of properties (-D)
982
983 const char* Arguments::get_property(const char* key) {
984 return PropertyList_get_value(system_properties(), key);
985 }
986
987 bool Arguments::add_property(const char* prop) {
988 const char* eq = strchr(prop, '=');
989 char* key;
990 // ns must be static--its address may be stored in a SystemProperty object.
991 const static char ns[1] = {0};
992 char* value = (char *)ns;
993
2417 // For components of the system classpath.
2418 SysClassPath scp(Arguments::get_sysclasspath());
2419 bool scp_assembly_required = false;
2420
2421 // Save default settings for some mode flags
2422 Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
2423 Arguments::_UseOnStackReplacement = UseOnStackReplacement;
2424 Arguments::_ClipInlining = ClipInlining;
2425 Arguments::_BackgroundCompilation = BackgroundCompilation;
2426
2427 // Setup flags for mixed which is the default
2428 set_mode_flags(_mixed);
2429
2430 // Parse JAVA_TOOL_OPTIONS environment variable (if present)
2431 jint result = parse_java_tool_options_environment_variable(&scp, &scp_assembly_required);
2432 if (result != JNI_OK) {
2433 return result;
2434 }
2435
2436 // Parse JavaVMInitArgs structure passed in
2437 result = parse_each_vm_init_arg(args, &scp, &scp_assembly_required, COMMAND_LINE);
2438 if (result != JNI_OK) {
2439 return result;
2440 }
2441
2442 if (AggressiveOpts) {
2443 // Insert alt-rt.jar between user-specified bootclasspath
2444 // prefix and the default bootclasspath. os::set_boot_path()
2445 // uses meta_index_dir as the default bootclasspath directory.
2446 const char* altclasses_jar = "alt-rt.jar";
2447 size_t altclasses_path_len = strlen(get_meta_index_dir()) + 1 +
2448 strlen(altclasses_jar);
2449 char* altclasses_path = NEW_C_HEAP_ARRAY(char, altclasses_path_len, mtInternal);
2450 strcpy(altclasses_path, get_meta_index_dir());
2451 strcat(altclasses_path, altclasses_jar);
2452 scp.add_suffix_to_prefix(altclasses_path);
2453 scp_assembly_required = true;
2454 FREE_C_HEAP_ARRAY(char, altclasses_path, mtInternal);
2455 }
2456
2457 // Parse _JAVA_OPTIONS environment variable (if present) (mimics classic VM)
2504 return false;
2505 }
2506
2507 if (strcmp(_name, JNI_LIB_SUFFIX) != 0) {
2508 return false;
2509 }
2510
2511 return true;
2512 }
2513
2514 if (strcmp(name, _hprof) == 0 || strcmp(name, _jdwp) == 0) {
2515 return true;
2516 }
2517
2518 return false;
2519 }
2520
2521 jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
2522 SysClassPath* scp_p,
2523 bool* scp_assembly_required_p,
2524 FlagValueOrigin origin) {
2525 // Remaining part of option string
2526 const char* tail;
2527
2528 // iterate over arguments
2529 for (int index = 0; index < args->nOptions; index++) {
2530 bool is_absolute_path = false; // for -agentpath vs -agentlib
2531
2532 const JavaVMOption* option = args->options + index;
2533
2534 if (!match_option(option, "-Djava.class.path", &tail) &&
2535 !match_option(option, "-Dsun.java.command", &tail) &&
2536 !match_option(option, "-Dsun.java.launcher", &tail)) {
2537
2538 // add all jvm options to the jvm_args string. This string
2539 // is used later to set the java.vm.args PerfData string constant.
2540 // the -Djava.class.path and the -Dsun.java.command options are
2541 // omitted from jvm_args string as each have their own PerfData
2542 // string constant object.
2543 build_jvm_args(option->optionString);
2544 }
3327 }
3328 *wrt = 0; // Zero terminate option
3329 }
3330 // Construct JavaVMInitArgs structure and parse as if it was part of the command line
3331 JavaVMInitArgs vm_args;
3332 vm_args.version = JNI_VERSION_1_2;
3333 vm_args.options = options;
3334 vm_args.nOptions = i;
3335 vm_args.ignoreUnrecognized = IgnoreUnrecognizedVMOptions;
3336
3337 if (PrintVMOptions) {
3338 const char* tail;
3339 for (int i = 0; i < vm_args.nOptions; i++) {
3340 const JavaVMOption *option = vm_args.options + i;
3341 if (match_option(option, "-XX:", &tail)) {
3342 logOption(tail);
3343 }
3344 }
3345 }
3346
3347 return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, ENVIRON_VAR));
3348 }
3349 return JNI_OK;
3350 }
3351
3352 void Arguments::set_shared_spaces_flags() {
3353 if (DumpSharedSpaces) {
3354 if (RequireSharedSpaces) {
3355 warning("cannot dump shared archive while using shared archive");
3356 }
3357 UseSharedSpaces = false;
3358 #ifdef _LP64
3359 if (!UseCompressedOops || !UseCompressedClassPointers) {
3360 vm_exit_during_initialization(
3361 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
3362 }
3363 } else {
3364 // UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.
3365 if (!UseCompressedOops || !UseCompressedClassPointers) {
3366 no_shared_spaces();
3367 }
|
608 }
609
610 // Describe an argument out of range error
611 void Arguments::describe_range_error(ArgsRange errcode) {
612 switch(errcode) {
613 case arg_too_big:
614 jio_fprintf(defaultStream::error_stream(),
615 "The specified size exceeds the maximum "
616 "representable size.\n");
617 break;
618 case arg_too_small:
619 case arg_unreadable:
620 case arg_in_range:
621 // do nothing for now
622 break;
623 default:
624 ShouldNotReachHere();
625 }
626 }
627
628 static bool set_bool_flag(char* name, bool value, Flag::Flags origin) {
629 return CommandLineFlags::boolAtPut(name, &value, origin);
630 }
631
632 static bool set_fp_numeric_flag(char* name, char* value, Flag::Flags origin) {
633 double v;
634 if (sscanf(value, "%lf", &v) != 1) {
635 return false;
636 }
637
638 if (CommandLineFlags::doubleAtPut(name, &v, origin)) {
639 return true;
640 }
641 return false;
642 }
643
644 static bool set_numeric_flag(char* name, char* value, Flag::Flags origin) {
645 julong v;
646 intx intx_v;
647 bool is_neg = false;
648 // Check the sign first since atomull() parses only unsigned values.
649 if (*value == '-') {
650 if (!CommandLineFlags::intxAt(name, &intx_v)) {
651 return false;
652 }
653 value++;
654 is_neg = true;
655 }
656 if (!atomull(value, &v)) {
657 return false;
658 }
659 intx_v = (intx) v;
660 if (is_neg) {
661 intx_v = -intx_v;
662 }
663 if (CommandLineFlags::intxAtPut(name, &intx_v, origin)) {
664 return true;
665 }
666 uintx uintx_v = (uintx) v;
667 if (!is_neg && CommandLineFlags::uintxAtPut(name, &uintx_v, origin)) {
668 return true;
669 }
670 uint64_t uint64_t_v = (uint64_t) v;
671 if (!is_neg && CommandLineFlags::uint64_tAtPut(name, &uint64_t_v, origin)) {
672 return true;
673 }
674 return false;
675 }
676
677 static bool set_string_flag(char* name, const char* value, Flag::Flags origin) {
678 if (!CommandLineFlags::ccstrAtPut(name, &value, origin)) return false;
679 // Contract: CommandLineFlags always returns a pointer that needs freeing.
680 FREE_C_HEAP_ARRAY(char, value, mtInternal);
681 return true;
682 }
683
684 static bool append_to_string_flag(char* name, const char* new_value, Flag::Flags origin) {
685 const char* old_value = "";
686 if (!CommandLineFlags::ccstrAt(name, &old_value)) return false;
687 size_t old_len = old_value != NULL ? strlen(old_value) : 0;
688 size_t new_len = strlen(new_value);
689 const char* value;
690 char* free_this_too = NULL;
691 if (old_len == 0) {
692 value = new_value;
693 } else if (new_len == 0) {
694 value = old_value;
695 } else {
696 char* buf = NEW_C_HEAP_ARRAY(char, old_len + 1 + new_len + 1, mtInternal);
697 // each new setting adds another LINE to the switch:
698 sprintf(buf, "%s\n%s", old_value, new_value);
699 value = buf;
700 free_this_too = buf;
701 }
702 (void) CommandLineFlags::ccstrAtPut(name, &value, origin);
703 // CommandLineFlags always returns a pointer that needs freeing.
704 FREE_C_HEAP_ARRAY(char, value, mtInternal);
705 if (free_this_too != NULL) {
706 // CommandLineFlags made its own copy, so I must delete my own temp. buffer.
707 FREE_C_HEAP_ARRAY(char, free_this_too, mtInternal);
708 }
709 return true;
710 }
711
712 bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
713
714 // range of acceptable characters spelled out for portability reasons
715 #define NAME_RANGE "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_]"
716 #define BUFLEN 255
717 char name[BUFLEN+1];
718 char dummy;
719
720 if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
721 return set_bool_flag(name, false, origin);
722 }
723 if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
724 return set_bool_flag(name, true, origin);
725 }
726
727 char punct;
728 if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "%c", name, &punct) == 2 && punct == '=') {
729 const char* value = strchr(arg, '=') + 1;
730 Flag* flag = Flag::find_flag(name, strlen(name));
731 if (flag != NULL && flag->is_ccstr()) {
732 if (flag->ccstr_accumulates()) {
833
834 void Arguments::print_jvm_flags_on(outputStream* st) {
835 if (_num_jvm_flags > 0) {
836 for (int i=0; i < _num_jvm_flags; i++) {
837 st->print("%s ", _jvm_flags_array[i]);
838 }
839 st->print_cr("");
840 }
841 }
842
843 void Arguments::print_jvm_args_on(outputStream* st) {
844 if (_num_jvm_args > 0) {
845 for (int i=0; i < _num_jvm_args; i++) {
846 st->print("%s ", _jvm_args_array[i]);
847 }
848 st->print_cr("");
849 }
850 }
851
852 bool Arguments::process_argument(const char* arg,
853 jboolean ignore_unrecognized, Flag::Flags origin) {
854
855 JDK_Version since = JDK_Version();
856
857 if (parse_argument(arg, origin) || ignore_unrecognized) {
858 return true;
859 }
860
861 bool has_plus_minus = (*arg == '+' || *arg == '-');
862 const char* const argname = has_plus_minus ? arg + 1 : arg;
863 if (is_newly_obsolete(arg, &since)) {
864 char version[256];
865 since.to_string(version, sizeof(version));
866 warning("ignoring option %s; support was removed in %s", argname, version);
867 return true;
868 }
869
870 // For locked flags, report a custom error message if available.
871 // Otherwise, report the standard unrecognized VM option.
872
873 size_t arg_len;
887 jio_fprintf(defaultStream::error_stream(),
888 "Missing +/- setting for VM option '%s'\n", argname);
889 } else if (!found_flag->is_bool() && has_plus_minus) {
890 jio_fprintf(defaultStream::error_stream(),
891 "Unexpected +/- setting in VM option '%s'\n", argname);
892 } else {
893 jio_fprintf(defaultStream::error_stream(),
894 "Improperly specified VM option '%s'\n", argname);
895 }
896 } else {
897 jio_fprintf(defaultStream::error_stream(), "%s", locked_message_buf);
898 }
899 } else {
900 jio_fprintf(defaultStream::error_stream(),
901 "Unrecognized VM option '%s'\n", argname);
902 Flag* fuzzy_matched = Flag::fuzzy_match((const char*)argname, arg_len, true);
903 if (fuzzy_matched != NULL) {
904 jio_fprintf(defaultStream::error_stream(),
905 "Did you mean '%s%s%s'?\n",
906 (fuzzy_matched->is_bool()) ? "(+/-)" : "",
907 fuzzy_matched->_name,
908 (fuzzy_matched->is_bool()) ? "" : "=<value>");
909 }
910 }
911
912 // allow for commandline "commenting out" options like -XX:#+Verbose
913 return arg[0] == '#';
914 }
915
916 bool Arguments::process_settings_file(const char* file_name, bool should_exist, jboolean ignore_unrecognized) {
917 FILE* stream = fopen(file_name, "rb");
918 if (stream == NULL) {
919 if (should_exist) {
920 jio_fprintf(defaultStream::error_stream(),
921 "Could not open settings file %s\n", file_name);
922 return false;
923 } else {
924 return true;
925 }
926 }
927
935 bool result = true;
936
937 int c = getc(stream);
938 while(c != EOF && pos < (int)(sizeof(token)-1)) {
939 if (in_white_space) {
940 if (in_comment) {
941 if (c == '\n') in_comment = false;
942 } else {
943 if (c == '#') in_comment = true;
944 else if (!isspace(c)) {
945 in_white_space = false;
946 token[pos++] = c;
947 }
948 }
949 } else {
950 if (c == '\n' || (!in_quote && isspace(c))) {
951 // token ends at newline, or at unquoted whitespace
952 // this allows a way to include spaces in string-valued options
953 token[pos] = '\0';
954 logOption(token);
955 result &= process_argument(token, ignore_unrecognized, Flag::CONFIG_FILE);
956 build_jvm_flags(token);
957 pos = 0;
958 in_white_space = true;
959 in_quote = false;
960 } else if (!in_quote && (c == '\'' || c == '"')) {
961 in_quote = true;
962 quote_c = c;
963 } else if (in_quote && (c == quote_c)) {
964 in_quote = false;
965 } else {
966 token[pos++] = c;
967 }
968 }
969 c = getc(stream);
970 }
971 if (pos > 0) {
972 token[pos] = '\0';
973 result &= process_argument(token, ignore_unrecognized, Flag::CONFIG_FILE);
974 build_jvm_flags(token);
975 }
976 fclose(stream);
977 return result;
978 }
979
980 //=============================================================================================================
981 // Parsing of properties (-D)
982
983 const char* Arguments::get_property(const char* key) {
984 return PropertyList_get_value(system_properties(), key);
985 }
986
987 bool Arguments::add_property(const char* prop) {
988 const char* eq = strchr(prop, '=');
989 char* key;
990 // ns must be static--its address may be stored in a SystemProperty object.
991 const static char ns[1] = {0};
992 char* value = (char *)ns;
993
2417 // For components of the system classpath.
2418 SysClassPath scp(Arguments::get_sysclasspath());
2419 bool scp_assembly_required = false;
2420
2421 // Save default settings for some mode flags
2422 Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
2423 Arguments::_UseOnStackReplacement = UseOnStackReplacement;
2424 Arguments::_ClipInlining = ClipInlining;
2425 Arguments::_BackgroundCompilation = BackgroundCompilation;
2426
2427 // Setup flags for mixed which is the default
2428 set_mode_flags(_mixed);
2429
2430 // Parse JAVA_TOOL_OPTIONS environment variable (if present)
2431 jint result = parse_java_tool_options_environment_variable(&scp, &scp_assembly_required);
2432 if (result != JNI_OK) {
2433 return result;
2434 }
2435
2436 // Parse JavaVMInitArgs structure passed in
2437 result = parse_each_vm_init_arg(args, &scp, &scp_assembly_required, Flag::COMMAND_LINE);
2438 if (result != JNI_OK) {
2439 return result;
2440 }
2441
2442 if (AggressiveOpts) {
2443 // Insert alt-rt.jar between user-specified bootclasspath
2444 // prefix and the default bootclasspath. os::set_boot_path()
2445 // uses meta_index_dir as the default bootclasspath directory.
2446 const char* altclasses_jar = "alt-rt.jar";
2447 size_t altclasses_path_len = strlen(get_meta_index_dir()) + 1 +
2448 strlen(altclasses_jar);
2449 char* altclasses_path = NEW_C_HEAP_ARRAY(char, altclasses_path_len, mtInternal);
2450 strcpy(altclasses_path, get_meta_index_dir());
2451 strcat(altclasses_path, altclasses_jar);
2452 scp.add_suffix_to_prefix(altclasses_path);
2453 scp_assembly_required = true;
2454 FREE_C_HEAP_ARRAY(char, altclasses_path, mtInternal);
2455 }
2456
2457 // Parse _JAVA_OPTIONS environment variable (if present) (mimics classic VM)
2504 return false;
2505 }
2506
2507 if (strcmp(_name, JNI_LIB_SUFFIX) != 0) {
2508 return false;
2509 }
2510
2511 return true;
2512 }
2513
2514 if (strcmp(name, _hprof) == 0 || strcmp(name, _jdwp) == 0) {
2515 return true;
2516 }
2517
2518 return false;
2519 }
2520
2521 jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
2522 SysClassPath* scp_p,
2523 bool* scp_assembly_required_p,
2524 Flag::Flags origin) {
2525 // Remaining part of option string
2526 const char* tail;
2527
2528 // iterate over arguments
2529 for (int index = 0; index < args->nOptions; index++) {
2530 bool is_absolute_path = false; // for -agentpath vs -agentlib
2531
2532 const JavaVMOption* option = args->options + index;
2533
2534 if (!match_option(option, "-Djava.class.path", &tail) &&
2535 !match_option(option, "-Dsun.java.command", &tail) &&
2536 !match_option(option, "-Dsun.java.launcher", &tail)) {
2537
2538 // add all jvm options to the jvm_args string. This string
2539 // is used later to set the java.vm.args PerfData string constant.
2540 // the -Djava.class.path and the -Dsun.java.command options are
2541 // omitted from jvm_args string as each have their own PerfData
2542 // string constant object.
2543 build_jvm_args(option->optionString);
2544 }
3327 }
3328 *wrt = 0; // Zero terminate option
3329 }
3330 // Construct JavaVMInitArgs structure and parse as if it was part of the command line
3331 JavaVMInitArgs vm_args;
3332 vm_args.version = JNI_VERSION_1_2;
3333 vm_args.options = options;
3334 vm_args.nOptions = i;
3335 vm_args.ignoreUnrecognized = IgnoreUnrecognizedVMOptions;
3336
3337 if (PrintVMOptions) {
3338 const char* tail;
3339 for (int i = 0; i < vm_args.nOptions; i++) {
3340 const JavaVMOption *option = vm_args.options + i;
3341 if (match_option(option, "-XX:", &tail)) {
3342 logOption(tail);
3343 }
3344 }
3345 }
3346
3347 return(parse_each_vm_init_arg(&vm_args, scp_p, scp_assembly_required_p, Flag::ENVIRON_VAR));
3348 }
3349 return JNI_OK;
3350 }
3351
3352 void Arguments::set_shared_spaces_flags() {
3353 if (DumpSharedSpaces) {
3354 if (RequireSharedSpaces) {
3355 warning("cannot dump shared archive while using shared archive");
3356 }
3357 UseSharedSpaces = false;
3358 #ifdef _LP64
3359 if (!UseCompressedOops || !UseCompressedClassPointers) {
3360 vm_exit_during_initialization(
3361 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off.", NULL);
3362 }
3363 } else {
3364 // UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces.
3365 if (!UseCompressedOops || !UseCompressedClassPointers) {
3366 no_shared_spaces();
3367 }
|