@@ -1775,14 +1775,20 @@ bool Arguments::sun_java_launcher_is_altjvm() {
17751775// ===========================================================================================================
17761776// Parsing of main arguments
17771777
1778- unsigned int addreads_count = 0 ;
1779- unsigned int addexports_count = 0 ;
1780- unsigned int addopens_count = 0 ;
1781- unsigned int patch_mod_count = 0 ;
1782- unsigned int enable_native_access_count = 0 ;
1778+ static unsigned int addreads_count = 0 ;
1779+ static unsigned int addexports_count = 0 ;
1780+ static unsigned int addopens_count = 0 ;
1781+ static unsigned int patch_mod_count = 0 ;
1782+ static unsigned int enable_native_access_count = 0 ;
1783+ static bool patch_mod_javabase = false ;
17831784
17841785// Check the consistency of vm_init_args
17851786bool Arguments::check_vm_args_consistency () {
1787+ // This may modify compiler flags. Must be called before CompilerConfig::check_args_consistency()
1788+ if (!CDSConfig::check_vm_args_consistency (patch_mod_javabase, mode_flag_cmd_line)) {
1789+ return false ;
1790+ }
1791+
17861792 // Method for adding checks for flag consistency.
17871793 // The intent is to warn the user of all possible conflicts,
17881794 // before returning an error.
@@ -1953,8 +1959,6 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *vm_options_args,
19531959 const JavaVMInitArgs *java_tool_options_args,
19541960 const JavaVMInitArgs *java_options_args,
19551961 const JavaVMInitArgs *cmd_line_args) {
1956- bool patch_mod_javabase = false ;
1957-
19581962 // Save default settings for some mode flags
19591963 Arguments::_AlwaysCompileLoopMethods = AlwaysCompileLoopMethods;
19601964 Arguments::_UseOnStackReplacement = UseOnStackReplacement;
@@ -1968,27 +1972,27 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *vm_options_args,
19681972 set_mode_flags (_mixed);
19691973
19701974 // Parse args structure generated from java.base vm options resource
1971- jint result = parse_each_vm_init_arg (vm_options_args, &patch_mod_javabase, JVMFlagOrigin::JIMAGE_RESOURCE);
1975+ jint result = parse_each_vm_init_arg (vm_options_args, JVMFlagOrigin::JIMAGE_RESOURCE);
19721976 if (result != JNI_OK) {
19731977 return result;
19741978 }
19751979
19761980 // Parse args structure generated from JAVA_TOOL_OPTIONS environment
19771981 // variable (if present).
1978- result = parse_each_vm_init_arg (java_tool_options_args, &patch_mod_javabase, JVMFlagOrigin::ENVIRON_VAR);
1982+ result = parse_each_vm_init_arg (java_tool_options_args, JVMFlagOrigin::ENVIRON_VAR);
19791983 if (result != JNI_OK) {
19801984 return result;
19811985 }
19821986
19831987 // Parse args structure generated from the command line flags.
1984- result = parse_each_vm_init_arg (cmd_line_args, &patch_mod_javabase, JVMFlagOrigin::COMMAND_LINE);
1988+ result = parse_each_vm_init_arg (cmd_line_args, JVMFlagOrigin::COMMAND_LINE);
19851989 if (result != JNI_OK) {
19861990 return result;
19871991 }
19881992
19891993 // Parse args structure generated from the _JAVA_OPTIONS environment
19901994 // variable (if present) (mimics classic VM)
1991- result = parse_each_vm_init_arg (java_options_args, &patch_mod_javabase, JVMFlagOrigin::ENVIRON_VAR);
1995+ result = parse_each_vm_init_arg (java_options_args, JVMFlagOrigin::ENVIRON_VAR);
19921996 if (result != JNI_OK) {
19931997 return result;
19941998 }
@@ -2009,7 +2013,7 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *vm_options_args,
20092013 SystemMemoryBarrier::initialize ();
20102014
20112015 // Do final processing now that all arguments have been parsed
2012- result = finalize_vm_init_args (patch_mod_javabase );
2016+ result = finalize_vm_init_args ();
20132017 if (result != JNI_OK) {
20142018 return result;
20152019 }
@@ -2064,7 +2068,7 @@ static bool valid_jdwp_agent(char *name, bool is_path) {
20642068}
20652069#endif
20662070
2067- int Arguments::process_patch_mod_option (const char * patch_mod_tail, bool * patch_mod_javabase ) {
2071+ int Arguments::process_patch_mod_option (const char * patch_mod_tail) {
20682072 // --patch-module=<module>=<file>(<pathsep><file>)*
20692073 assert (patch_mod_tail != nullptr , " Unexpected null patch-module value" );
20702074 // Find the equal sign between the module name and the path specification
@@ -2080,7 +2084,7 @@ int Arguments::process_patch_mod_option(const char* patch_mod_tail, bool* patch_
20802084 memcpy (module_name, patch_mod_tail, module_len);
20812085 *(module_name + module_len) = ' \0 ' ;
20822086 // The path piece begins one past the module_equal sign
2083- add_patch_mod_prefix (module_name, module_equal + 1 , patch_mod_javabase );
2087+ add_patch_mod_prefix (module_name, module_equal + 1 );
20842088 FREE_C_HEAP_ARRAY (char , module_name);
20852089 if (!create_numbered_module_property (" jdk.module.patch" , patch_mod_tail, patch_mod_count++)) {
20862090 return JNI_ENOMEM;
@@ -2146,7 +2150,7 @@ jint Arguments::parse_xss(const JavaVMOption* option, const char* tail, intx* ou
21462150 return JNI_OK;
21472151}
21482152
2149- jint Arguments::parse_each_vm_init_arg (const JavaVMInitArgs* args, bool * patch_mod_javabase, JVMFlagOrigin origin) {
2153+ jint Arguments::parse_each_vm_init_arg (const JavaVMInitArgs* args, JVMFlagOrigin origin) {
21502154 // For match_option to return remaining or value part of option string
21512155 const char * tail;
21522156
@@ -2273,7 +2277,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
22732277 }
22742278 } else if (match_option (option, " --patch-module=" , &tail)) {
22752279 // --patch-module=<module>=<file>(<pathsep><file>)*
2276- int res = process_patch_mod_option (tail, patch_mod_javabase );
2280+ int res = process_patch_mod_option (tail);
22772281 if (res != JNI_OK) {
22782282 return res;
22792283 }
@@ -2822,16 +2826,16 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
28222826 return JNI_OK;
28232827}
28242828
2825- void Arguments::add_patch_mod_prefix (const char * module_name, const char * path, bool * patch_mod_javabase ) {
2829+ void Arguments::add_patch_mod_prefix (const char * module_name, const char * path) {
28262830 // For java.base check for duplicate --patch-module options being specified on the command line.
28272831 // This check is only required for java.base, all other duplicate module specifications
28282832 // will be checked during module system initialization. The module system initialization
28292833 // will throw an ExceptionInInitializerError if this situation occurs.
28302834 if (strcmp (module_name, JAVA_BASE_NAME) == 0 ) {
2831- if (* patch_mod_javabase) {
2835+ if (patch_mod_javabase) {
28322836 vm_exit_during_initialization (" Cannot specify " JAVA_BASE_NAME " more than once to --patch-module" );
28332837 } else {
2834- * patch_mod_javabase = true ;
2838+ patch_mod_javabase = true ;
28352839 }
28362840 }
28372841
@@ -2883,7 +2887,7 @@ void Arguments::fix_appclasspath() {
28832887 }
28842888}
28852889
2886- jint Arguments::finalize_vm_init_args (bool patch_mod_javabase ) {
2890+ jint Arguments::finalize_vm_init_args () {
28872891 // check if the default lib/endorsed directory exists; if so, error
28882892 char path[JVM_MAXPATHLEN];
28892893 const char * fileSep = os::file_separator ();
@@ -2957,9 +2961,6 @@ jint Arguments::finalize_vm_init_args(bool patch_mod_javabase) {
29572961 return JNI_ERR;
29582962 }
29592963
2960- if (!CDSConfig::check_vm_args_consistency (patch_mod_javabase, mode_flag_cmd_line)) {
2961- return JNI_ERR;
2962- }
29632964
29642965#ifndef CAN_SHOW_REGISTERS_ON_ASSERT
29652966 UNSUPPORTED_OPTION (ShowRegistersOnAssert);
0 commit comments