< prev index next >

src/hotspot/share/runtime/arguments.hpp

Print this page

  1 /*
  2  * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *

 74   void append_value(const char *value);
 75 
 76   PathString(const char* value);
 77   ~PathString();
 78 
 79   // for JVM_ReadSystemPropertiesInfo
 80   static int value_offset_in_bytes()  { return (int)offset_of(PathString, _value);  }
 81 };
 82 
 83 // ModulePatchPath records the module/path pair as specified to --patch-module.
 84 class ModulePatchPath : public CHeapObj<mtInternal> {
 85 private:
 86   char* _module_name;
 87   PathString* _path;
 88 public:
 89   ModulePatchPath(const char* module_name, const char* path);
 90   ~ModulePatchPath();
 91 
 92   inline const char* module_name() const { return _module_name; }
 93   inline char* path_string() const { return _path->value(); }

 94 };
 95 
 96 // Element describing System and User (-Dkey=value flags) defined property.
 97 //
 98 // An internal SystemProperty is one that has been removed in
 99 // jdk.internal.VM.saveAndRemoveProperties, like jdk.boot.class.path.append.
100 //
101 class SystemProperty : public PathString {
102  private:
103   char*           _key;
104   SystemProperty* _next;
105   bool            _internal;
106   bool            _writeable;
107 
108  public:
109   // Accessors
110   char* value() const                 { return PathString::value(); }
111   const char* key() const             { return _key; }
112   bool internal() const               { return _internal; }
113   SystemProperty* next() const        { return _next; }

273   static void set_heap_size();
274 
275   // Bytecode rewriting
276   static void set_bytecode_flags();
277 
278   // Invocation API hooks
279   static abort_hook_t     _abort_hook;
280   static exit_hook_t      _exit_hook;
281   static vfprintf_hook_t  _vfprintf_hook;
282 
283   // System properties
284   static bool add_property(const char* prop, PropertyWriteable writeable=WriteableProperty,
285                            PropertyInternal internal=ExternalProperty);
286 
287   // Used for module system related properties: converted from command-line flags.
288   // Basic properties are writeable as they operate as "last one wins" and will get overwritten.
289   // Numbered properties are never writeable, and always internal.
290   static bool create_module_property(const char* prop_name, const char* prop_value, PropertyInternal internal);
291   static bool create_numbered_module_property(const char* prop_base_name, const char* prop_value, unsigned int count);
292 
293   static int process_patch_mod_option(const char* patch_mod_tail, bool* patch_mod_javabase);
294 
295   // Aggressive optimization flags.
296   static jint set_aggressive_opts_flags();
297 
298   static jint set_aggressive_heap_flags();
299 
300   // Argument parsing
301   static bool parse_argument(const char* arg, JVMFlagOrigin origin);
302   static bool process_argument(const char* arg, jboolean ignore_unrecognized, JVMFlagOrigin origin);
303   static void process_java_launcher_argument(const char*, void*);
304   static jint parse_options_environment_variable(const char* name, ScopedVMInitArgs* vm_args);
305   static jint parse_java_tool_options_environment_variable(ScopedVMInitArgs* vm_args);
306   static jint parse_java_options_environment_variable(ScopedVMInitArgs* vm_args);
307   static jint parse_vm_options_file(const char* file_name, ScopedVMInitArgs* vm_args);
308   static jint parse_options_buffer(const char* name, char* buffer, const size_t buf_len, ScopedVMInitArgs* vm_args);
309   static jint parse_xss(const JavaVMOption* option, const char* tail, intx* out_ThreadStackSize);
310   static jint insert_vm_options_file(const JavaVMInitArgs* args,
311                                      const char* vm_options_file,
312                                      const int vm_options_file_pos,
313                                      ScopedVMInitArgs* vm_options_file_args,
314                                      ScopedVMInitArgs* args_out);
315   static bool args_contains_vm_options_file_arg(const JavaVMInitArgs* args);
316   static jint expand_vm_options_as_needed(const JavaVMInitArgs* args_in,
317                                           ScopedVMInitArgs* mod_args,
318                                           JavaVMInitArgs** args_out);
319   static jint match_special_option_and_act(const JavaVMInitArgs* args,
320                                            ScopedVMInitArgs* args_out);
321 
322   static bool handle_deprecated_print_gc_flags();
323 
324   static jint parse_vm_init_args(const JavaVMInitArgs *vm_options_args,
325                                  const JavaVMInitArgs *java_tool_options_args,
326                                  const JavaVMInitArgs *java_options_args,
327                                  const JavaVMInitArgs *cmd_line_args);
328   static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, JVMFlagOrigin origin);
329   static jint finalize_vm_init_args(bool patch_mod_javabase);
330   static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type);
331 
332   static bool is_bad_option(const JavaVMOption* option, jboolean ignore) {
333     return is_bad_option(option, ignore, nullptr);
334   }
335 
336   static void describe_range_error(ArgsRange errcode);
337   static ArgsRange check_memory_size(julong size, julong min_size, julong max_size);
338   static ArgsRange parse_memory_size(const char* s, julong* long_arg,
339                                      julong min_size, julong max_size = max_uintx);
340 
341   // methods to build strings from individual args
342   static void build_jvm_args(const char* arg);
343   static void build_jvm_flags(const char* arg);
344   static void add_string(char*** bldarray, int* count, const char* arg);
345   static const char* build_resource_string(char** args, int count);
346 
347   // Returns true if the flag is obsolete (and not yet expired).
348   // In this case the 'version' buffer is filled in with
349   // the version number when the flag became obsolete.

457   static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v,
458                                       PropertyAppendable append, PropertyWriteable writeable,
459                                       PropertyInternal internal);
460   static const char* PropertyList_get_value(SystemProperty* plist, const char* key);
461   static const char* PropertyList_get_readable_value(SystemProperty* plist, const char* key);
462   static int  PropertyList_count(SystemProperty* pl);
463   static int  PropertyList_readable_count(SystemProperty* pl);
464 
465   static bool is_internal_module_property(const char* option);
466   static bool is_add_modules_property(const char* key);
467   static unsigned int addmods_count() { return  _addmods_count; }
468   static bool is_module_path_property(const char* key);
469 
470   // Miscellaneous System property value getter and setters.
471   static void set_dll_dir(const char *value) { _sun_boot_library_path->set_value(value); }
472   static void set_java_home(const char *value) { _java_home->set_value(value); }
473   static void set_library_path(const char *value) { _java_library_path->set_value(value); }
474   static void set_ext_dirs(char *value)     { _ext_dirs = os::strdup_check_oom(value); }
475 
476   // Set up the underlying pieces of the boot class path
477   static void add_patch_mod_prefix(const char *module_name, const char *path, bool* patch_mod_javabase);

478   static void set_boot_class_path(const char *value, bool has_jimage) {
479     // During start up, set by os::set_boot_path()
480     assert(get_boot_class_path() == nullptr, "Boot class path previously set");
481     _boot_class_path->set_value(value);
482     _has_jimage = has_jimage;
483   }
484   static void append_sysclasspath(const char *value) {
485     _boot_class_path->append_value(value);
486     _jdk_boot_class_path_append->append_value(value);
487   }
488 
489   static GrowableArray<ModulePatchPath*>* get_patch_mod_prefix() { return _patch_mod_prefix; }
490   static char* get_boot_class_path() { return _boot_class_path->value(); }
491   static bool has_jimage() { return _has_jimage; }
492 
493   static char* get_java_home()    { return _java_home->value(); }
494   static char* get_dll_dir()      { return _sun_boot_library_path->value(); }
495   static char* get_appclasspath() { return _java_class_path->value(); }
496   static void  fix_appclasspath();
497 

  1 /*
  2  * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *

 74   void append_value(const char *value);
 75 
 76   PathString(const char* value);
 77   ~PathString();
 78 
 79   // for JVM_ReadSystemPropertiesInfo
 80   static int value_offset_in_bytes()  { return (int)offset_of(PathString, _value);  }
 81 };
 82 
 83 // ModulePatchPath records the module/path pair as specified to --patch-module.
 84 class ModulePatchPath : public CHeapObj<mtInternal> {
 85 private:
 86   char* _module_name;
 87   PathString* _path;
 88 public:
 89   ModulePatchPath(const char* module_name, const char* path);
 90   ~ModulePatchPath();
 91 
 92   inline const char* module_name() const { return _module_name; }
 93   inline char* path_string() const { return _path->value(); }
 94   inline void append_path(const char* path) { _path->append_value(path); }
 95 };
 96 
 97 // Element describing System and User (-Dkey=value flags) defined property.
 98 //
 99 // An internal SystemProperty is one that has been removed in
100 // jdk.internal.VM.saveAndRemoveProperties, like jdk.boot.class.path.append.
101 //
102 class SystemProperty : public PathString {
103  private:
104   char*           _key;
105   SystemProperty* _next;
106   bool            _internal;
107   bool            _writeable;
108 
109  public:
110   // Accessors
111   char* value() const                 { return PathString::value(); }
112   const char* key() const             { return _key; }
113   bool internal() const               { return _internal; }
114   SystemProperty* next() const        { return _next; }

274   static void set_heap_size();
275 
276   // Bytecode rewriting
277   static void set_bytecode_flags();
278 
279   // Invocation API hooks
280   static abort_hook_t     _abort_hook;
281   static exit_hook_t      _exit_hook;
282   static vfprintf_hook_t  _vfprintf_hook;
283 
284   // System properties
285   static bool add_property(const char* prop, PropertyWriteable writeable=WriteableProperty,
286                            PropertyInternal internal=ExternalProperty);
287 
288   // Used for module system related properties: converted from command-line flags.
289   // Basic properties are writeable as they operate as "last one wins" and will get overwritten.
290   // Numbered properties are never writeable, and always internal.
291   static bool create_module_property(const char* prop_name, const char* prop_value, PropertyInternal internal);
292   static bool create_numbered_module_property(const char* prop_base_name, const char* prop_value, unsigned int count);
293 
294   static int process_patch_mod_option(const char* patch_mod_tail);
295 
296   // Aggressive optimization flags.
297   static jint set_aggressive_opts_flags();
298 
299   static jint set_aggressive_heap_flags();
300 
301   // Argument parsing
302   static bool parse_argument(const char* arg, JVMFlagOrigin origin);
303   static bool process_argument(const char* arg, jboolean ignore_unrecognized, JVMFlagOrigin origin);
304   static void process_java_launcher_argument(const char*, void*);
305   static jint parse_options_environment_variable(const char* name, ScopedVMInitArgs* vm_args);
306   static jint parse_java_tool_options_environment_variable(ScopedVMInitArgs* vm_args);
307   static jint parse_java_options_environment_variable(ScopedVMInitArgs* vm_args);
308   static jint parse_vm_options_file(const char* file_name, ScopedVMInitArgs* vm_args);
309   static jint parse_options_buffer(const char* name, char* buffer, const size_t buf_len, ScopedVMInitArgs* vm_args);
310   static jint parse_xss(const JavaVMOption* option, const char* tail, intx* out_ThreadStackSize);
311   static jint insert_vm_options_file(const JavaVMInitArgs* args,
312                                      const char* vm_options_file,
313                                      const int vm_options_file_pos,
314                                      ScopedVMInitArgs* vm_options_file_args,
315                                      ScopedVMInitArgs* args_out);
316   static bool args_contains_vm_options_file_arg(const JavaVMInitArgs* args);
317   static jint expand_vm_options_as_needed(const JavaVMInitArgs* args_in,
318                                           ScopedVMInitArgs* mod_args,
319                                           JavaVMInitArgs** args_out);
320   static jint match_special_option_and_act(const JavaVMInitArgs* args,
321                                            ScopedVMInitArgs* args_out);
322 
323   static bool handle_deprecated_print_gc_flags();
324 
325   static jint parse_vm_init_args(const JavaVMInitArgs *vm_options_args,
326                                  const JavaVMInitArgs *java_tool_options_args,
327                                  const JavaVMInitArgs *java_options_args,
328                                  const JavaVMInitArgs *cmd_line_args);
329   static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, JVMFlagOrigin origin);
330   static jint finalize_vm_init_args();
331   static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type);
332 
333   static bool is_bad_option(const JavaVMOption* option, jboolean ignore) {
334     return is_bad_option(option, ignore, nullptr);
335   }
336 
337   static void describe_range_error(ArgsRange errcode);
338   static ArgsRange check_memory_size(julong size, julong min_size, julong max_size);
339   static ArgsRange parse_memory_size(const char* s, julong* long_arg,
340                                      julong min_size, julong max_size = max_uintx);
341 
342   // methods to build strings from individual args
343   static void build_jvm_args(const char* arg);
344   static void build_jvm_flags(const char* arg);
345   static void add_string(char*** bldarray, int* count, const char* arg);
346   static const char* build_resource_string(char** args, int count);
347 
348   // Returns true if the flag is obsolete (and not yet expired).
349   // In this case the 'version' buffer is filled in with
350   // the version number when the flag became obsolete.

458   static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v,
459                                       PropertyAppendable append, PropertyWriteable writeable,
460                                       PropertyInternal internal);
461   static const char* PropertyList_get_value(SystemProperty* plist, const char* key);
462   static const char* PropertyList_get_readable_value(SystemProperty* plist, const char* key);
463   static int  PropertyList_count(SystemProperty* pl);
464   static int  PropertyList_readable_count(SystemProperty* pl);
465 
466   static bool is_internal_module_property(const char* option);
467   static bool is_add_modules_property(const char* key);
468   static unsigned int addmods_count() { return  _addmods_count; }
469   static bool is_module_path_property(const char* key);
470 
471   // Miscellaneous System property value getter and setters.
472   static void set_dll_dir(const char *value) { _sun_boot_library_path->set_value(value); }
473   static void set_java_home(const char *value) { _java_home->set_value(value); }
474   static void set_library_path(const char *value) { _java_library_path->set_value(value); }
475   static void set_ext_dirs(char *value)     { _ext_dirs = os::strdup_check_oom(value); }
476 
477   // Set up the underlying pieces of the boot class path
478   static void add_patch_mod_prefix(const char *module_name, const char *path, bool allow_append, bool allow_cds);
479   static int finalize_patch_module();
480   static void set_boot_class_path(const char *value, bool has_jimage) {
481     // During start up, set by os::set_boot_path()
482     assert(get_boot_class_path() == nullptr, "Boot class path previously set");
483     _boot_class_path->set_value(value);
484     _has_jimage = has_jimage;
485   }
486   static void append_sysclasspath(const char *value) {
487     _boot_class_path->append_value(value);
488     _jdk_boot_class_path_append->append_value(value);
489   }
490 
491   static GrowableArray<ModulePatchPath*>* get_patch_mod_prefix() { return _patch_mod_prefix; }
492   static char* get_boot_class_path() { return _boot_class_path->value(); }
493   static bool has_jimage() { return _has_jimage; }
494 
495   static char* get_java_home()    { return _java_home->value(); }
496   static char* get_dll_dir()      { return _sun_boot_library_path->value(); }
497   static char* get_appclasspath() { return _java_class_path->value(); }
498   static void  fix_appclasspath();
499 
< prev index next >