58 #include "utilities/stringUtils.hpp" |
58 #include "utilities/stringUtils.hpp" |
59 #if INCLUDE_JFR |
59 #if INCLUDE_JFR |
60 #include "jfr/jfr.hpp" |
60 #include "jfr/jfr.hpp" |
61 #endif |
61 #endif |
62 |
62 |
63 // Note: This is a special bug reporting site for the JVM |
|
64 #ifdef VENDOR_URL_VM_BUG |
|
65 # define DEFAULT_VENDOR_URL_BUG VENDOR_URL_VM_BUG |
|
66 #else |
|
67 # define DEFAULT_VENDOR_URL_BUG "http://bugreport.java.com/bugreport/crash.jsp" |
|
68 #endif |
|
69 #define DEFAULT_JAVA_LAUNCHER "generic" |
63 #define DEFAULT_JAVA_LAUNCHER "generic" |
70 |
64 |
71 char* Arguments::_jvm_flags_file = NULL; |
65 char* Arguments::_jvm_flags_file = NULL; |
72 char** Arguments::_jvm_flags_array = NULL; |
66 char** Arguments::_jvm_flags_array = NULL; |
73 int Arguments::_num_jvm_flags = 0; |
67 int Arguments::_num_jvm_flags = 0; |
78 const char* Arguments::_gc_log_filename = NULL; |
72 const char* Arguments::_gc_log_filename = NULL; |
79 size_t Arguments::_conservative_max_heap_alignment = 0; |
73 size_t Arguments::_conservative_max_heap_alignment = 0; |
80 Arguments::Mode Arguments::_mode = _mixed; |
74 Arguments::Mode Arguments::_mode = _mixed; |
81 bool Arguments::_java_compiler = false; |
75 bool Arguments::_java_compiler = false; |
82 bool Arguments::_xdebug_mode = false; |
76 bool Arguments::_xdebug_mode = false; |
83 const char* Arguments::_java_vendor_url_bug = DEFAULT_VENDOR_URL_BUG; |
77 const char* Arguments::_java_vendor_url_bug = NULL; |
84 const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER; |
78 const char* Arguments::_sun_java_launcher = DEFAULT_JAVA_LAUNCHER; |
85 bool Arguments::_sun_java_launcher_is_altjvm = false; |
79 bool Arguments::_sun_java_launcher_is_altjvm = false; |
86 |
80 |
87 // These parameters are reset in method parse_vm_init_args() |
81 // These parameters are reset in method parse_vm_init_args() |
88 bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods; |
82 bool Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods; |
1420 _java_command = os::strdup_check_oom(value, mtArguments); |
1414 _java_command = os::strdup_check_oom(value, mtArguments); |
1421 if (old_java_command != NULL) { |
1415 if (old_java_command != NULL) { |
1422 os::free(old_java_command); |
1416 os::free(old_java_command); |
1423 } |
1417 } |
1424 } else if (strcmp(key, "java.vendor.url.bug") == 0) { |
1418 } else if (strcmp(key, "java.vendor.url.bug") == 0) { |
|
1419 // If this property is set on the command line then its value will be |
|
1420 // displayed in VM error logs as the URL at which to submit such logs. |
|
1421 // Normally the URL displayed in error logs is different from the value |
|
1422 // of this system property, so a different property should have been |
|
1423 // used here, but we leave this as-is in case someone depends upon it. |
1425 const char* old_java_vendor_url_bug = _java_vendor_url_bug; |
1424 const char* old_java_vendor_url_bug = _java_vendor_url_bug; |
1426 // save it in _java_vendor_url_bug, so JVM fatal error handler can access |
1425 // save it in _java_vendor_url_bug, so JVM fatal error handler can access |
1427 // its value without going through the property list or making a Java call. |
1426 // its value without going through the property list or making a Java call. |
1428 _java_vendor_url_bug = os::strdup_check_oom(value, mtArguments); |
1427 _java_vendor_url_bug = os::strdup_check_oom(value, mtArguments); |
1429 if (old_java_vendor_url_bug != DEFAULT_VENDOR_URL_BUG) { |
1428 if (old_java_vendor_url_bug != NULL) { |
1430 assert(old_java_vendor_url_bug != NULL, "_java_vendor_url_bug is NULL"); |
|
1431 os::free((void *)old_java_vendor_url_bug); |
1429 os::free((void *)old_java_vendor_url_bug); |
1432 } |
1430 } |
1433 } |
1431 } |
1434 |
1432 |
1435 // Create new property and add at the end of the list |
1433 // Create new property and add at the end of the list |
2183 return check_memory_size(*long_arg, min_size, max_size); |
2181 return check_memory_size(*long_arg, min_size, max_size); |
2184 } |
2182 } |
2185 |
2183 |
2186 // Parse JavaVMInitArgs structure |
2184 // Parse JavaVMInitArgs structure |
2187 |
2185 |
2188 jint Arguments::parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args, |
2186 jint Arguments::parse_vm_init_args(const JavaVMInitArgs *vm_options_args, |
|
2187 const JavaVMInitArgs *java_tool_options_args, |
2189 const JavaVMInitArgs *java_options_args, |
2188 const JavaVMInitArgs *java_options_args, |
2190 const JavaVMInitArgs *cmd_line_args) { |
2189 const JavaVMInitArgs *cmd_line_args) { |
2191 bool patch_mod_javabase = false; |
2190 bool patch_mod_javabase = false; |
2192 |
2191 |
2193 // Save default settings for some mode flags |
2192 // Save default settings for some mode flags |
2201 } |
2200 } |
2202 |
2201 |
2203 // Setup flags for mixed which is the default |
2202 // Setup flags for mixed which is the default |
2204 set_mode_flags(_mixed); |
2203 set_mode_flags(_mixed); |
2205 |
2204 |
|
2205 // Parse args structure generated from java.base vm options resource |
|
2206 jint result = parse_each_vm_init_arg(vm_options_args, &patch_mod_javabase, JVMFlag::JIMAGE_RESOURCE); |
|
2207 if (result != JNI_OK) { |
|
2208 return result; |
|
2209 } |
|
2210 |
2206 // Parse args structure generated from JAVA_TOOL_OPTIONS environment |
2211 // Parse args structure generated from JAVA_TOOL_OPTIONS environment |
2207 // variable (if present). |
2212 // variable (if present). |
2208 jint result = parse_each_vm_init_arg(java_tool_options_args, &patch_mod_javabase, JVMFlag::ENVIRON_VAR); |
2213 result = parse_each_vm_init_arg(java_tool_options_args, &patch_mod_javabase, JVMFlag::ENVIRON_VAR); |
2209 if (result != JNI_OK) { |
2214 if (result != JNI_OK) { |
2210 return result; |
2215 return result; |
2211 } |
2216 } |
2212 |
2217 |
2213 // Parse args structure generated from the command line flags. |
2218 // Parse args structure generated from the command line flags. |
2709 // "-Djdk.module.addmods=java.sql" |
2714 // "-Djdk.module.addmods=java.sql" |
2710 if (is_internal_module_property(option->optionString + 2)) { |
2715 if (is_internal_module_property(option->optionString + 2)) { |
2711 needs_module_property_warning = true; |
2716 needs_module_property_warning = true; |
2712 continue; |
2717 continue; |
2713 } |
2718 } |
2714 |
|
2715 if (!add_property(tail)) { |
2719 if (!add_property(tail)) { |
2716 return JNI_ENOMEM; |
2720 return JNI_ENOMEM; |
2717 } |
2721 } |
2718 // Out of the box management support |
2722 // Out of the box management support |
2719 if (match_option(option, "-Dcom.sun.management", &tail)) { |
2723 if (match_option(option, "-Dcom.sun.management", &tail)) { |
3830 |
3834 |
3831 // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed. |
3835 // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed. |
3832 const char* hotspotrc = ".hotspotrc"; |
3836 const char* hotspotrc = ".hotspotrc"; |
3833 bool settings_file_specified = false; |
3837 bool settings_file_specified = false; |
3834 bool needs_hotspotrc_warning = false; |
3838 bool needs_hotspotrc_warning = false; |
|
3839 ScopedVMInitArgs initial_vm_options_args(""); |
3835 ScopedVMInitArgs initial_java_tool_options_args("env_var='JAVA_TOOL_OPTIONS'"); |
3840 ScopedVMInitArgs initial_java_tool_options_args("env_var='JAVA_TOOL_OPTIONS'"); |
3836 ScopedVMInitArgs initial_java_options_args("env_var='_JAVA_OPTIONS'"); |
3841 ScopedVMInitArgs initial_java_options_args("env_var='_JAVA_OPTIONS'"); |
3837 |
3842 |
3838 // Pointers to current working set of containers |
3843 // Pointers to current working set of containers |
3839 JavaVMInitArgs* cur_cmd_args; |
3844 JavaVMInitArgs* cur_cmd_args; |
|
3845 JavaVMInitArgs* cur_vm_options_args; |
3840 JavaVMInitArgs* cur_java_options_args; |
3846 JavaVMInitArgs* cur_java_options_args; |
3841 JavaVMInitArgs* cur_java_tool_options_args; |
3847 JavaVMInitArgs* cur_java_tool_options_args; |
3842 |
3848 |
3843 // Containers for modified/expanded options |
3849 // Containers for modified/expanded options |
3844 ScopedVMInitArgs mod_cmd_args("cmd_line_args"); |
3850 ScopedVMInitArgs mod_cmd_args("cmd_line_args"); |
|
3851 ScopedVMInitArgs mod_vm_options_args("vm_options_args"); |
3845 ScopedVMInitArgs mod_java_tool_options_args("env_var='JAVA_TOOL_OPTIONS'"); |
3852 ScopedVMInitArgs mod_java_tool_options_args("env_var='JAVA_TOOL_OPTIONS'"); |
3846 ScopedVMInitArgs mod_java_options_args("env_var='_JAVA_OPTIONS'"); |
3853 ScopedVMInitArgs mod_java_options_args("env_var='_JAVA_OPTIONS'"); |
3847 |
3854 |
3848 |
3855 |
3849 jint code = |
3856 jint code = |
3853 } |
3860 } |
3854 |
3861 |
3855 code = parse_java_options_environment_variable(&initial_java_options_args); |
3862 code = parse_java_options_environment_variable(&initial_java_options_args); |
3856 if (code != JNI_OK) { |
3863 if (code != JNI_OK) { |
3857 return code; |
3864 return code; |
|
3865 } |
|
3866 |
|
3867 // Parse the options in the /java.base/jdk/internal/vm/options resource, if present |
|
3868 char *vmoptions = ClassLoader::lookup_vm_options(); |
|
3869 if (vmoptions != NULL) { |
|
3870 code = parse_options_buffer("vm options resource", vmoptions, strlen(vmoptions), &initial_vm_options_args); |
|
3871 FREE_C_HEAP_ARRAY(char, vmoptions); |
|
3872 if (code != JNI_OK) { |
|
3873 return code; |
|
3874 } |
3858 } |
3875 } |
3859 |
3876 |
3860 code = expand_vm_options_as_needed(initial_java_tool_options_args.get(), |
3877 code = expand_vm_options_as_needed(initial_java_tool_options_args.get(), |
3861 &mod_java_tool_options_args, |
3878 &mod_java_tool_options_args, |
3862 &cur_java_tool_options_args); |
3879 &cur_java_tool_options_args); |
3872 } |
3889 } |
3873 |
3890 |
3874 code = expand_vm_options_as_needed(initial_java_options_args.get(), |
3891 code = expand_vm_options_as_needed(initial_java_options_args.get(), |
3875 &mod_java_options_args, |
3892 &mod_java_options_args, |
3876 &cur_java_options_args); |
3893 &cur_java_options_args); |
|
3894 if (code != JNI_OK) { |
|
3895 return code; |
|
3896 } |
|
3897 |
|
3898 code = expand_vm_options_as_needed(initial_vm_options_args.get(), |
|
3899 &mod_vm_options_args, |
|
3900 &cur_vm_options_args); |
3877 if (code != JNI_OK) { |
3901 if (code != JNI_OK) { |
3878 return code; |
3902 return code; |
3879 } |
3903 } |
3880 |
3904 |
3881 const char* flags_file = Arguments::get_jvm_flags_file(); |
3905 const char* flags_file = Arguments::get_jvm_flags_file(); |
3913 print_options(cur_cmd_args); |
3937 print_options(cur_cmd_args); |
3914 print_options(cur_java_options_args); |
3938 print_options(cur_java_options_args); |
3915 } |
3939 } |
3916 |
3940 |
3917 // Parse JavaVMInitArgs structure passed in, as well as JAVA_TOOL_OPTIONS and _JAVA_OPTIONS |
3941 // Parse JavaVMInitArgs structure passed in, as well as JAVA_TOOL_OPTIONS and _JAVA_OPTIONS |
3918 jint result = parse_vm_init_args(cur_java_tool_options_args, |
3942 jint result = parse_vm_init_args(cur_vm_options_args, |
|
3943 cur_java_tool_options_args, |
3919 cur_java_options_args, |
3944 cur_java_options_args, |
3920 cur_cmd_args); |
3945 cur_cmd_args); |
3921 |
3946 |
3922 if (result != JNI_OK) { |
3947 if (result != JNI_OK) { |
3923 return result; |
3948 return result; |