< 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; }

236   // sun.java.launcher, private property to provide information about
237   // java launcher
238   static const char* _sun_java_launcher;
239 
240   // was this VM created via the -XXaltjvm=<path> option
241   static bool   _sun_java_launcher_is_altjvm;
242 
243   // for legacy gc options (-verbose:gc and -Xloggc:)
244   static LegacyGCLogging _legacyGCLogging;
245 
246   // Value of the conservative maximum heap alignment needed
247   static size_t  _conservative_max_heap_alignment;
248 
249   // Operation modi
250   static Mode _mode;
251   static void set_mode_flags(Mode mode);
252 
253   // preview features
254   static bool _enable_preview;
255 


256   // Used to save default settings
257   static bool _AlwaysCompileLoopMethods;
258   static bool _UseOnStackReplacement;
259   static bool _BackgroundCompilation;
260   static bool _ClipInlining;
261 
262   // GC ergonomics
263   static void set_conservative_max_heap_alignment();
264   static void set_use_compressed_oops();
265   static void set_use_compressed_klass_ptrs();
266   static jint set_ergonomics_flags();
267   static void set_shared_spaces_flags_and_archive_paths();
268   // Limits the given heap size by the maximum amount of virtual
269   // memory this process is currently allowed to use. It also takes
270   // the virtual-to-physical ratio of the current GC into account.
271   static size_t limit_heap_by_allocatable_memory(size_t size);
272   // Setup heap size
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.

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



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

  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; }

237   // sun.java.launcher, private property to provide information about
238   // java launcher
239   static const char* _sun_java_launcher;
240 
241   // was this VM created via the -XXaltjvm=<path> option
242   static bool   _sun_java_launcher_is_altjvm;
243 
244   // for legacy gc options (-verbose:gc and -Xloggc:)
245   static LegacyGCLogging _legacyGCLogging;
246 
247   // Value of the conservative maximum heap alignment needed
248   static size_t  _conservative_max_heap_alignment;
249 
250   // Operation modi
251   static Mode _mode;
252   static void set_mode_flags(Mode mode);
253 
254   // preview features
255   static bool _enable_preview;
256 
257   static bool _module_patching_disables_cds;
258 
259   // Used to save default settings
260   static bool _AlwaysCompileLoopMethods;
261   static bool _UseOnStackReplacement;
262   static bool _BackgroundCompilation;
263   static bool _ClipInlining;
264 
265   // GC ergonomics
266   static void set_conservative_max_heap_alignment();
267   static void set_use_compressed_oops();
268   static void set_use_compressed_klass_ptrs();
269   static jint set_ergonomics_flags();
270   static void set_shared_spaces_flags_and_archive_paths();
271   // Limits the given heap size by the maximum amount of virtual
272   // memory this process is currently allowed to use. It also takes
273   // the virtual-to-physical ratio of the current GC into account.
274   static size_t limit_heap_by_allocatable_memory(size_t size);
275   // Setup heap size
276   static void set_heap_size();
277 
278   // Bytecode rewriting
279   static void set_bytecode_flags();
280 
281   // Invocation API hooks
282   static abort_hook_t     _abort_hook;
283   static exit_hook_t      _exit_hook;
284   static vfprintf_hook_t  _vfprintf_hook;
285 
286   // System properties
287   static bool add_property(const char* prop, PropertyWriteable writeable=WriteableProperty,
288                            PropertyInternal internal=ExternalProperty);
289 
290   // Used for module system related properties: converted from command-line flags.
291   // Basic properties are writeable as they operate as "last one wins" and will get overwritten.
292   // Numbered properties are never writeable, and always internal.
293   static bool create_module_property(const char* prop_name, const char* prop_value, PropertyInternal internal);
294   static bool create_numbered_module_property(const char* prop_base_name, const char* prop_value, unsigned int count);
295 
296   static int process_patch_mod_option(const char* patch_mod_tail);
297 
298   // Aggressive optimization flags.
299   static jint set_aggressive_opts_flags();
300 
301   static jint set_aggressive_heap_flags();
302 
303   // Argument parsing
304   static bool parse_argument(const char* arg, JVMFlagOrigin origin);
305   static bool process_argument(const char* arg, jboolean ignore_unrecognized, JVMFlagOrigin origin);
306   static void process_java_launcher_argument(const char*, void*);
307   static jint parse_options_environment_variable(const char* name, ScopedVMInitArgs* vm_args);
308   static jint parse_java_tool_options_environment_variable(ScopedVMInitArgs* vm_args);
309   static jint parse_java_options_environment_variable(ScopedVMInitArgs* vm_args);
310   static jint parse_vm_options_file(const char* file_name, ScopedVMInitArgs* vm_args);
311   static jint parse_options_buffer(const char* name, char* buffer, const size_t buf_len, ScopedVMInitArgs* vm_args);
312   static jint parse_xss(const JavaVMOption* option, const char* tail, intx* out_ThreadStackSize);
313   static jint insert_vm_options_file(const JavaVMInitArgs* args,
314                                      const char* vm_options_file,
315                                      const int vm_options_file_pos,
316                                      ScopedVMInitArgs* vm_options_file_args,
317                                      ScopedVMInitArgs* args_out);
318   static bool args_contains_vm_options_file_arg(const JavaVMInitArgs* args);
319   static jint expand_vm_options_as_needed(const JavaVMInitArgs* args_in,
320                                           ScopedVMInitArgs* mod_args,
321                                           JavaVMInitArgs** args_out);
322   static jint match_special_option_and_act(const JavaVMInitArgs* args,
323                                            ScopedVMInitArgs* args_out);
324 
325   static bool handle_deprecated_print_gc_flags();
326 
327   static jint parse_vm_init_args(const JavaVMInitArgs *vm_options_args,
328                                  const JavaVMInitArgs *java_tool_options_args,
329                                  const JavaVMInitArgs *java_options_args,
330                                  const JavaVMInitArgs *cmd_line_args);
331   static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, JVMFlagOrigin origin);
332   static jint finalize_vm_init_args();
333   static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type);
334 
335   static bool is_bad_option(const JavaVMOption* option, jboolean ignore) {
336     return is_bad_option(option, ignore, nullptr);
337   }
338 
339   static void describe_range_error(ArgsRange errcode);
340   static ArgsRange check_memory_size(julong size, julong min_size, julong max_size);
341   static ArgsRange parse_memory_size(const char* s, julong* long_arg,
342                                      julong min_size, julong max_size = max_uintx);
343 
344   // methods to build strings from individual args
345   static void build_jvm_args(const char* arg);
346   static void build_jvm_flags(const char* arg);
347   static void add_string(char*** bldarray, int* count, const char* arg);
348   static const char* build_resource_string(char** args, int count);
349 
350   // Returns true if the flag is obsolete (and not yet expired).
351   // In this case the 'version' buffer is filled in with
352   // the version number when the flag became obsolete.

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