1 /*
   2  * Copyright (c) 1997, 2016, 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  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_ARGUMENTS_HPP
  26 #define SHARE_VM_RUNTIME_ARGUMENTS_HPP
  27 
  28 #include "logging/logLevel.hpp"
  29 #include "logging/logTag.hpp"
  30 #include "runtime/java.hpp"
  31 #include "runtime/os.hpp"
  32 #include "runtime/perfData.hpp"
  33 #include "utilities/debug.hpp"
  34 
  35 // Arguments parses the command line and recognizes options
  36 
  37 // Invocation API hook typedefs (these should really be defined in jni.hpp)
  38 extern "C" {
  39   typedef void (JNICALL *abort_hook_t)(void);
  40   typedef void (JNICALL *exit_hook_t)(jint code);
  41   typedef jint (JNICALL *vfprintf_hook_t)(FILE *fp, const char *format, va_list args)  ATTRIBUTE_PRINTF(2, 0);
  42 }
  43 
  44 // PathString is used as:
  45 //  - the underlying value for a SystemProperty
  46 //  - the path portion of an -Xpatch module/path pair
  47 //  - the string that represents the system boot class path, Arguments::_system_boot_class_path.
  48 class PathString : public CHeapObj<mtArguments> {
  49  protected:
  50   char* _value;
  51  public:
  52   char* value() const { return _value; }
  53 
  54   bool set_value(const char *value) {
  55     if (_value != NULL) {
  56       FreeHeap(_value);
  57     }
  58     _value = AllocateHeap(strlen(value)+1, mtArguments);
  59     assert(_value != NULL, "Unable to allocate space for new path value");
  60     if (_value != NULL) {
  61       strcpy(_value, value);
  62     } else {
  63       // not able to allocate
  64       return false;
  65     }
  66     return true;
  67   }
  68 
  69   void append_value(const char *value) {
  70     char *sp;
  71     size_t len = 0;
  72     if (value != NULL) {
  73       len = strlen(value);
  74       if (_value != NULL) {
  75         len += strlen(_value);
  76       }
  77       sp = AllocateHeap(len+2, mtArguments);
  78       assert(sp != NULL, "Unable to allocate space for new append path value");
  79       if (sp != NULL) {
  80         if (_value != NULL) {
  81           strcpy(sp, _value);
  82           strcat(sp, os::path_separator());
  83           strcat(sp, value);
  84           FreeHeap(_value);
  85         } else {
  86           strcpy(sp, value);
  87         }
  88         _value = sp;
  89       }
  90     }
  91   }
  92 
  93   PathString(const char* value) {
  94     if (value == NULL) {
  95       _value = NULL;
  96     } else {
  97       _value = AllocateHeap(strlen(value)+1, mtArguments);
  98       strcpy(_value, value);
  99     }
 100   }
 101 
 102   ~PathString() {
 103     if (_value != NULL) {
 104       FreeHeap(_value);
 105       _value = NULL;
 106     }
 107   }
 108 };
 109 
 110 // ModuleXPatchPath records the module/path pair as specified to -Xpatch.
 111 class ModuleXPatchPath : public CHeapObj<mtInternal> {
 112 private:
 113   char* _module_name;
 114   PathString* _path;
 115 public:
 116   ModuleXPatchPath(const char* module_name, const char* path) {
 117     assert(module_name != NULL && path != NULL, "Invalid module name or path value");
 118     size_t len = strlen(module_name) + 1;
 119     _module_name = AllocateHeap(len, mtInternal);
 120     strncpy(_module_name, module_name, len); // copy the trailing null
 121     _path =  new PathString(path);
 122   }
 123 
 124   ~ModuleXPatchPath() {
 125     if (_module_name != NULL) {
 126       FreeHeap(_module_name);
 127       _module_name = NULL;
 128     }
 129     if (_path != NULL) {
 130       delete _path;
 131       _path = NULL;
 132     }
 133   }
 134 
 135   inline void set_path(const char* path) { _path->set_value(path); }
 136   inline const char* module_name() const { return _module_name; }
 137   inline char* path_string() const { return _path->value(); }
 138 };
 139 
 140 // Element describing System and User (-Dkey=value flags) defined property.
 141 //
 142 // An internal SystemProperty is one that has been removed in
 143 // jdk.internal.VM.saveAndRemoveProperties, like jdk.boot.class.path.append.
 144 //
 145 class SystemProperty : public PathString {
 146  private:
 147   char*           _key;
 148   SystemProperty* _next;
 149   bool            _internal;
 150   bool            _writeable;
 151   bool writeable() { return _writeable; }
 152 
 153  public:
 154   // Accessors
 155   char* value() const                 { return PathString::value(); }
 156   const char* key() const             { return _key; }
 157   bool internal() const               { return _internal; }
 158   SystemProperty* next() const        { return _next; }
 159   void set_next(SystemProperty* next) { _next = next; }
 160 
 161   // A system property should only have its value set
 162   // via an external interface if it is a writeable property.
 163   // The internal, non-writeable property jdk.boot.class.path.append
 164   // is the only exception to this rule.  It can be set externally
 165   // via -Xbootclasspath/a or JVMTI OnLoad phase call to AddToBootstrapClassLoaderSearch.
 166   // In those cases for jdk.boot.class.path.append, the base class
 167   // set_value and append_value methods are called directly.
 168   bool set_writeable_value(const char *value) {
 169     if (writeable()) {
 170       return set_value(value);
 171     }
 172     return false;
 173   }
 174 
 175   // Constructor
 176   SystemProperty(const char* key, const char* value, bool writeable, bool internal = false) : PathString(value) {
 177     if (key == NULL) {
 178       _key = NULL;
 179     } else {
 180       _key = AllocateHeap(strlen(key)+1, mtArguments);
 181       strcpy(_key, key);
 182     }
 183     _next = NULL;
 184     _internal = internal;
 185     _writeable = writeable;
 186   }
 187 };
 188 
 189 
 190 // For use by -agentlib, -agentpath and -Xrun
 191 class AgentLibrary : public CHeapObj<mtArguments> {
 192   friend class AgentLibraryList;
 193 public:
 194   // Is this library valid or not. Don't rely on os_lib == NULL as statically
 195   // linked lib could have handle of RTLD_DEFAULT which == 0 on some platforms
 196   enum AgentState {
 197     agent_invalid = 0,
 198     agent_valid   = 1
 199   };
 200 
 201  private:
 202   char*           _name;
 203   char*           _options;
 204   void*           _os_lib;
 205   bool            _is_absolute_path;
 206   bool            _is_static_lib;
 207   AgentState      _state;
 208   AgentLibrary*   _next;
 209 
 210  public:
 211   // Accessors
 212   const char* name() const                  { return _name; }
 213   char* options() const                     { return _options; }
 214   bool is_absolute_path() const             { return _is_absolute_path; }
 215   void* os_lib() const                      { return _os_lib; }
 216   void set_os_lib(void* os_lib)             { _os_lib = os_lib; }
 217   AgentLibrary* next() const                { return _next; }
 218   bool is_static_lib() const                { return _is_static_lib; }
 219   void set_static_lib(bool is_static_lib)   { _is_static_lib = is_static_lib; }
 220   bool valid()                              { return (_state == agent_valid); }
 221   void set_valid()                          { _state = agent_valid; }
 222   void set_invalid()                        { _state = agent_invalid; }
 223 
 224   // Constructor
 225   AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib) {
 226     _name = AllocateHeap(strlen(name)+1, mtArguments);
 227     strcpy(_name, name);
 228     if (options == NULL) {
 229       _options = NULL;
 230     } else {
 231       _options = AllocateHeap(strlen(options)+1, mtArguments);
 232       strcpy(_options, options);
 233     }
 234     _is_absolute_path = is_absolute_path;
 235     _os_lib = os_lib;
 236     _next = NULL;
 237     _state = agent_invalid;
 238     _is_static_lib = false;
 239   }
 240 };
 241 
 242 // maintain an order of entry list of AgentLibrary
 243 class AgentLibraryList VALUE_OBJ_CLASS_SPEC {
 244  private:
 245   AgentLibrary*   _first;
 246   AgentLibrary*   _last;
 247  public:
 248   bool is_empty() const                     { return _first == NULL; }
 249   AgentLibrary* first() const               { return _first; }
 250 
 251   // add to the end of the list
 252   void add(AgentLibrary* lib) {
 253     if (is_empty()) {
 254       _first = _last = lib;
 255     } else {
 256       _last->_next = lib;
 257       _last = lib;
 258     }
 259     lib->_next = NULL;
 260   }
 261 
 262   // search for and remove a library known to be in the list
 263   void remove(AgentLibrary* lib) {
 264     AgentLibrary* curr;
 265     AgentLibrary* prev = NULL;
 266     for (curr = first(); curr != NULL; prev = curr, curr = curr->next()) {
 267       if (curr == lib) {
 268         break;
 269       }
 270     }
 271     assert(curr != NULL, "always should be found");
 272 
 273     if (curr != NULL) {
 274       // it was found, by-pass this library
 275       if (prev == NULL) {
 276         _first = curr->_next;
 277       } else {
 278         prev->_next = curr->_next;
 279       }
 280       if (curr == _last) {
 281         _last = prev;
 282       }
 283       curr->_next = NULL;
 284     }
 285   }
 286 
 287   AgentLibraryList() {
 288     _first = NULL;
 289     _last = NULL;
 290   }
 291 };
 292 
 293 // Helper class for controlling the lifetime of JavaVMInitArgs objects.
 294 class ScopedVMInitArgs;
 295 
 296 // Most logging functions require 5 tags. Some of them may be _NO_TAG.
 297 typedef struct {
 298   const char* alias_name;
 299   LogLevelType level;
 300   bool exactMatch;
 301   LogTagType tag0;
 302   LogTagType tag1;
 303   LogTagType tag2;
 304   LogTagType tag3;
 305   LogTagType tag4;
 306   LogTagType tag5;
 307 } AliasedLoggingFlag;
 308 
 309 class Arguments : AllStatic {
 310   friend class VMStructs;
 311   friend class JvmtiExport;
 312   friend class CodeCacheExtensions;
 313  public:
 314   // Operation modi
 315   enum Mode {
 316     _int,       // corresponds to -Xint
 317     _mixed,     // corresponds to -Xmixed
 318     _comp       // corresponds to -Xcomp
 319   };
 320 
 321   enum ArgsRange {
 322     arg_unreadable = -3,
 323     arg_too_small  = -2,
 324     arg_too_big    = -1,
 325     arg_in_range   = 0
 326   };
 327 
 328  private:
 329 
 330   // a pointer to the flags file name if it is specified
 331   static char*  _jvm_flags_file;
 332   // an array containing all flags specified in the .hotspotrc file
 333   static char** _jvm_flags_array;
 334   static int    _num_jvm_flags;
 335   // an array containing all jvm arguments specified in the command line
 336   static char** _jvm_args_array;
 337   static int    _num_jvm_args;
 338   // string containing all java command (class/jarfile name and app args)
 339   static char* _java_command;
 340 
 341   // Property list
 342   static SystemProperty* _system_properties;
 343 
 344   // Quick accessor to System properties in the list:
 345   static SystemProperty *_sun_boot_library_path;
 346   static SystemProperty *_java_library_path;
 347   static SystemProperty *_java_home;
 348   static SystemProperty *_java_class_path;
 349   static SystemProperty *_jdk_boot_class_path_append;
 350 
 351   // -Xpatch:module=<file>(<pathsep><file>)*
 352   // Each element contains the associated module name, path
 353   // string pair as specified to -Xpatch.
 354   static GrowableArray<ModuleXPatchPath*>* _xpatchprefix;
 355 
 356   // The constructed value of the system class path after
 357   // argument processing and JVMTI OnLoad additions via
 358   // calls to AddToBootstrapClassLoaderSearch.  This is the
 359   // final form before ClassLoader::setup_bootstrap_search().
 360   // Note: since -Xpatch is a module name/path pair, the system
 361   // boot class path string no longer contains the "prefix" to
 362   // the boot class path base piece as it did when
 363   // -Xbootclasspath/p was supported.
 364   static PathString *_system_boot_class_path;
 365 
 366   // Set if a modular java runtime image is present vs. a build with exploded modules
 367   static bool _has_jimage;
 368 
 369   // temporary: to emit warning if the default ext dirs are not empty.
 370   // remove this variable when the warning is no longer needed.
 371   static char* _ext_dirs;
 372 
 373   // java.vendor.url.bug, bug reporting URL for fatal errors.
 374   static const char* _java_vendor_url_bug;
 375 
 376   // sun.java.launcher, private property to provide information about
 377   // java launcher
 378   static const char* _sun_java_launcher;
 379 
 380   // sun.java.launcher.pid, private property
 381   static int    _sun_java_launcher_pid;
 382 
 383   // was this VM created via the -XXaltjvm=<path> option
 384   static bool   _sun_java_launcher_is_altjvm;
 385 
 386   // Option flags
 387   static bool   _has_profile;
 388   static const char*  _gc_log_filename;
 389   // Value of the conservative maximum heap alignment needed
 390   static size_t  _conservative_max_heap_alignment;
 391 
 392   static uintx  _min_heap_size;
 393 
 394   // -Xrun arguments
 395   static AgentLibraryList _libraryList;
 396   static void add_init_library(const char* name, char* options)
 397     { _libraryList.add(new AgentLibrary(name, options, false, NULL)); }
 398 
 399   // -agentlib and -agentpath arguments
 400   static AgentLibraryList _agentList;
 401   static void add_init_agent(const char* name, char* options, bool absolute_path)
 402     { _agentList.add(new AgentLibrary(name, options, absolute_path, NULL)); }
 403 
 404   // Late-binding agents not started via arguments
 405   static void add_loaded_agent(AgentLibrary *agentLib)
 406     { _agentList.add(agentLib); }
 407   static void add_loaded_agent(const char* name, char* options, bool absolute_path, void* os_lib)
 408     { _agentList.add(new AgentLibrary(name, options, absolute_path, os_lib)); }
 409 
 410   // Operation modi
 411   static Mode _mode;
 412   static void set_mode_flags(Mode mode);
 413   static bool _java_compiler;
 414   static void set_java_compiler(bool arg) { _java_compiler = arg; }
 415   static bool java_compiler()   { return _java_compiler; }
 416 
 417   // -Xdebug flag
 418   static bool _xdebug_mode;
 419   static void set_xdebug_mode(bool arg) { _xdebug_mode = arg; }
 420   static bool xdebug_mode()             { return _xdebug_mode; }
 421 
 422   // Used to save default settings
 423   static bool _AlwaysCompileLoopMethods;
 424   static bool _UseOnStackReplacement;
 425   static bool _BackgroundCompilation;
 426   static bool _ClipInlining;
 427   static bool _CIDynamicCompilePriority;
 428   static intx _Tier3InvokeNotifyFreqLog;
 429   static intx _Tier4InvocationThreshold;
 430 
 431   // Tiered
 432   static void set_tiered_flags();
 433   // GC ergonomics
 434   static void set_conservative_max_heap_alignment();
 435   static void set_use_compressed_oops();
 436   static void set_use_compressed_klass_ptrs();
 437   static void set_ergonomics_flags();
 438   static void set_shared_spaces_flags();
 439   // limits the given memory size by the maximum amount of memory this process is
 440   // currently allowed to allocate or reserve.
 441   static julong limit_by_allocatable_memory(julong size);
 442   // Setup heap size
 443   static void set_heap_size();
 444   // Based on automatic selection criteria, should the
 445   // low pause collector be used.
 446   static bool should_auto_select_low_pause_collector();
 447 
 448   // Bytecode rewriting
 449   static void set_bytecode_flags();
 450 
 451   // Invocation API hooks
 452   static abort_hook_t     _abort_hook;
 453   static exit_hook_t      _exit_hook;
 454   static vfprintf_hook_t  _vfprintf_hook;
 455 
 456   // System properties
 457   static bool add_property(const char* prop);
 458 
 459   // Miscellaneous system property setter
 460   static bool append_to_addmods_property(const char* module_name);
 461 
 462   // Aggressive optimization flags.
 463   static jint set_aggressive_opts_flags();
 464 
 465   static jint set_aggressive_heap_flags();
 466 
 467   // Argument parsing
 468   static void do_pd_flag_adjustments();
 469   static bool parse_argument(const char* arg, Flag::Flags origin);
 470   static bool process_argument(const char* arg, jboolean ignore_unrecognized, Flag::Flags origin);
 471   static void process_java_launcher_argument(const char*, void*);
 472   static void process_java_compiler_argument(const char* arg);
 473   static jint parse_options_environment_variable(const char* name, ScopedVMInitArgs* vm_args);
 474   static jint parse_java_tool_options_environment_variable(ScopedVMInitArgs* vm_args);
 475   static jint parse_java_options_environment_variable(ScopedVMInitArgs* vm_args);
 476   static jint parse_vm_options_file(const char* file_name, ScopedVMInitArgs* vm_args);
 477   static jint parse_options_buffer(const char* name, char* buffer, const size_t buf_len, ScopedVMInitArgs* vm_args);
 478   static jint insert_vm_options_file(const JavaVMInitArgs* args,
 479                                      const char* vm_options_file,
 480                                      const int vm_options_file_pos,
 481                                      ScopedVMInitArgs* vm_options_file_args,
 482                                      ScopedVMInitArgs* args_out);
 483   static bool args_contains_vm_options_file_arg(const JavaVMInitArgs* args);
 484   static jint expand_vm_options_as_needed(const JavaVMInitArgs* args_in,
 485                                           ScopedVMInitArgs* mod_args,
 486                                           JavaVMInitArgs** args_out);
 487   static jint match_special_option_and_act(const JavaVMInitArgs* args,
 488                                            ScopedVMInitArgs* args_out);
 489 
 490   static bool handle_deprecated_print_gc_flags();
 491 
 492   static jint parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args,
 493                                  const JavaVMInitArgs *java_options_args,
 494                                  const JavaVMInitArgs *cmd_line_args);
 495   static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* xpatch_javabase, Flag::Flags origin);
 496   static jint finalize_vm_init_args();
 497   static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type);
 498 
 499   static bool is_bad_option(const JavaVMOption* option, jboolean ignore) {
 500     return is_bad_option(option, ignore, NULL);
 501   }
 502 
 503   static void describe_range_error(ArgsRange errcode);
 504   static ArgsRange check_memory_size(julong size, julong min_size);
 505   static ArgsRange parse_memory_size(const char* s, julong* long_arg,
 506                                      julong min_size);
 507   // Parse a string for a unsigned integer.  Returns true if value
 508   // is an unsigned integer greater than or equal to the minimum
 509   // parameter passed and returns the value in uintx_arg.  Returns
 510   // false otherwise, with uintx_arg undefined.
 511   static bool parse_uintx(const char* value, uintx* uintx_arg,
 512                           uintx min_size);
 513 
 514   // methods to build strings from individual args
 515   static void build_jvm_args(const char* arg);
 516   static void build_jvm_flags(const char* arg);
 517   static void add_string(char*** bldarray, int* count, const char* arg);
 518   static const char* build_resource_string(char** args, int count);
 519 
 520   static bool methodExists(
 521     char* className, char* methodName,
 522     int classesNum, char** classes, bool* allMethods,
 523     int methodsNum, char** methods, bool* allClasses
 524   );
 525 
 526   static void parseOnlyLine(
 527     const char* line,
 528     short* classesNum, short* classesMax, char*** classes, bool** allMethods,
 529     short* methodsNum, short* methodsMax, char*** methods, bool** allClasses
 530   );
 531 
 532   // Returns true if the flag is obsolete (and not yet expired).
 533   // In this case the 'version' buffer is filled in with
 534   // the version number when the flag became obsolete.
 535   static bool is_obsolete_flag(const char* flag_name, JDK_Version* version);
 536 
 537 #ifndef PRODUCT
 538   static const char* removed_develop_logging_flag_name(const char* name);
 539 #endif // PRODUCT
 540 
 541   // Returns 1 if the flag is deprecated (and not yet obsolete or expired).
 542   //     In this case the 'version' buffer is filled in with the version number when
 543   //     the flag became deprecated.
 544   // Returns -1 if the flag is expired or obsolete.
 545   // Returns 0 otherwise.
 546   static int is_deprecated_flag(const char* flag_name, JDK_Version* version);
 547 
 548   // Return the real name for the flag passed on the command line (either an alias name or "flag_name").
 549   static const char* real_flag_name(const char *flag_name);
 550 
 551   // Return the "real" name for option arg if arg is an alias, and print a warning if arg is deprecated.
 552   // Return NULL if the arg has expired.
 553   static const char* handle_aliases_and_deprecation(const char* arg, bool warn);
 554   static bool lookup_logging_aliases(const char* arg, char* buffer);
 555   static AliasedLoggingFlag catch_logging_aliases(const char* name, bool on);
 556   static short  CompileOnlyClassesNum;
 557   static short  CompileOnlyClassesMax;
 558   static char** CompileOnlyClasses;
 559   static bool*  CompileOnlyAllMethods;
 560 
 561   static short  CompileOnlyMethodsNum;
 562   static short  CompileOnlyMethodsMax;
 563   static char** CompileOnlyMethods;
 564   static bool*  CompileOnlyAllClasses;
 565 
 566   static short  InterpretOnlyClassesNum;
 567   static short  InterpretOnlyClassesMax;
 568   static char** InterpretOnlyClasses;
 569   static bool*  InterpretOnlyAllMethods;
 570 
 571   static bool   CheckCompileOnly;
 572 
 573   static char*  SharedArchivePath;
 574 
 575  public:
 576   // Scale compile thresholds
 577   // Returns threshold scaled with CompileThresholdScaling
 578   static intx scaled_compile_threshold(intx threshold, double scale);
 579   static intx scaled_compile_threshold(intx threshold) {
 580     return scaled_compile_threshold(threshold, CompileThresholdScaling);
 581   }
 582   // Returns freq_log scaled with CompileThresholdScaling
 583   static intx scaled_freq_log(intx freq_log, double scale);
 584   static intx scaled_freq_log(intx freq_log) {
 585     return scaled_freq_log(freq_log, CompileThresholdScaling);
 586   }
 587 
 588   // Parses the arguments, first phase
 589   static jint parse(const JavaVMInitArgs* args);
 590   // Apply ergonomics
 591   static void select_gc();
 592   static jint apply_ergo();
 593   // Adjusts the arguments after the OS have adjusted the arguments
 594   static jint adjust_after_os();
 595 
 596   static void set_gc_specific_flags();
 597   static bool gc_selected(); // whether a gc has been selected
 598   static void select_gc_ergonomically();
 599 #if INCLUDE_JVMCI
 600   // Check consistency of jvmci vm argument settings.
 601   static bool check_jvmci_args_consistency();
 602 #endif
 603   // Check for consistency in the selection of the garbage collector.
 604   static bool check_gc_consistency();        // Check user-selected gc
 605   // Check consistency or otherwise of VM argument settings
 606   static bool check_vm_args_consistency();
 607   // Used by os_solaris
 608   static bool process_settings_file(const char* file_name, bool should_exist, jboolean ignore_unrecognized);
 609 
 610   static size_t conservative_max_heap_alignment() { return _conservative_max_heap_alignment; }
 611   // Return the maximum size a heap with compressed oops can take
 612   static size_t max_heap_for_compressed_oops();
 613 
 614   // return a char* array containing all options
 615   static char** jvm_flags_array()          { return _jvm_flags_array; }
 616   static char** jvm_args_array()           { return _jvm_args_array; }
 617   static int num_jvm_flags()               { return _num_jvm_flags; }
 618   static int num_jvm_args()                { return _num_jvm_args; }
 619   // return the arguments passed to the Java application
 620   static const char* java_command()        { return _java_command; }
 621 
 622   // print jvm_flags, jvm_args and java_command
 623   static void print_on(outputStream* st);
 624   static void print_summary_on(outputStream* st);
 625 
 626   // convenient methods to get and set jvm_flags_file
 627   static const char* get_jvm_flags_file()  { return _jvm_flags_file; }
 628   static void set_jvm_flags_file(const char *value) {
 629     if (_jvm_flags_file != NULL) {
 630       os::free(_jvm_flags_file);
 631     }
 632     _jvm_flags_file = os::strdup_check_oom(value);
 633   }
 634   // convenient methods to obtain / print jvm_flags and jvm_args
 635   static const char* jvm_flags()           { return build_resource_string(_jvm_flags_array, _num_jvm_flags); }
 636   static const char* jvm_args()            { return build_resource_string(_jvm_args_array, _num_jvm_args); }
 637   static void print_jvm_flags_on(outputStream* st);
 638   static void print_jvm_args_on(outputStream* st);
 639 
 640   // -Dkey=value flags
 641   static SystemProperty*  system_properties()   { return _system_properties; }
 642   static const char*    get_property(const char* key);
 643 
 644   // -Djava.vendor.url.bug
 645   static const char* java_vendor_url_bug()  { return _java_vendor_url_bug; }
 646 
 647   // -Dsun.java.launcher
 648   static const char* sun_java_launcher()    { return _sun_java_launcher; }
 649   // Was VM created by a Java launcher?
 650   static bool created_by_java_launcher();
 651   // -Dsun.java.launcher.is_altjvm
 652   static bool sun_java_launcher_is_altjvm();
 653   // -Dsun.java.launcher.pid
 654   static int sun_java_launcher_pid()        { return _sun_java_launcher_pid; }
 655 
 656   // -Xprof
 657   static bool has_profile()                 { return _has_profile; }
 658 
 659   // -Xms
 660   static size_t min_heap_size()             { return _min_heap_size; }
 661   static void  set_min_heap_size(size_t v)  { _min_heap_size = v;  }
 662 
 663   // -Xrun
 664   static AgentLibrary* libraries()          { return _libraryList.first(); }
 665   static bool init_libraries_at_startup()   { return !_libraryList.is_empty(); }
 666   static void convert_library_to_agent(AgentLibrary* lib)
 667                                             { _libraryList.remove(lib);
 668                                               _agentList.add(lib); }
 669 
 670   // -agentlib -agentpath
 671   static AgentLibrary* agents()             { return _agentList.first(); }
 672   static bool init_agents_at_startup()      { return !_agentList.is_empty(); }
 673 
 674   // abort, exit, vfprintf hooks
 675   static abort_hook_t    abort_hook()       { return _abort_hook; }
 676   static exit_hook_t     exit_hook()        { return _exit_hook; }
 677   static vfprintf_hook_t vfprintf_hook()    { return _vfprintf_hook; }
 678 
 679   static bool GetCheckCompileOnly ()        { return CheckCompileOnly; }
 680 
 681   static const char* GetSharedArchivePath() { return SharedArchivePath; }
 682 
 683   static bool CompileMethod(char* className, char* methodName) {
 684     return
 685       methodExists(
 686         className, methodName,
 687         CompileOnlyClassesNum, CompileOnlyClasses, CompileOnlyAllMethods,
 688         CompileOnlyMethodsNum, CompileOnlyMethods, CompileOnlyAllClasses
 689       );
 690   }
 691 
 692   // Java launcher properties
 693   static void process_sun_java_launcher_properties(JavaVMInitArgs* args);
 694 
 695   // System properties
 696   static void init_system_properties();
 697 
 698   // Update/Initialize System properties after JDK version number is known
 699   static void init_version_specific_system_properties();
 700 
 701   // Property List manipulation
 702   static void PropertyList_add(SystemProperty *element);
 703   static void PropertyList_add(SystemProperty** plist, SystemProperty *element);
 704   static void PropertyList_add(SystemProperty** plist, const char* k, const char* v);
 705   static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v) {
 706     PropertyList_unique_add(plist, k, v, false);
 707   }
 708   static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v, jboolean append);
 709   static const char* PropertyList_get_value(SystemProperty* plist, const char* key);
 710   static int  PropertyList_count(SystemProperty* pl);
 711   static const char* PropertyList_get_key_at(SystemProperty* pl,int index);
 712   static char* PropertyList_get_value_at(SystemProperty* pl,int index);
 713 
 714   // Miscellaneous System property value getter and setters.
 715   static void set_dll_dir(const char *value) { _sun_boot_library_path->set_value(value); }
 716   static void set_java_home(const char *value) { _java_home->set_value(value); }
 717   static void set_library_path(const char *value) { _java_library_path->set_value(value); }
 718   static void set_ext_dirs(char *value)     { _ext_dirs = os::strdup_check_oom(value); }
 719 
 720   // Set up the underlying pieces of the system boot class path
 721   static void add_xpatchprefix(const char *module_name, const char *path, bool* xpatch_javabase);
 722   static void set_sysclasspath(const char *value, bool has_jimage) {
 723     // During start up, set by os::set_boot_path()
 724     assert(get_sysclasspath() == NULL, "System boot class path previously set");
 725     _system_boot_class_path->set_value(value);
 726     _has_jimage = has_jimage;
 727   }
 728   static void append_sysclasspath(const char *value) {
 729     _system_boot_class_path->append_value(value);
 730     _jdk_boot_class_path_append->append_value(value);
 731   }
 732 
 733   static GrowableArray<ModuleXPatchPath*>* get_xpatchprefix() { return _xpatchprefix; }
 734   static char* get_sysclasspath() { return _system_boot_class_path->value(); }
 735   static char* get_jdk_boot_class_path_append() { return _jdk_boot_class_path_append->value(); }
 736   static bool has_jimage() { return _has_jimage; }
 737 
 738   static char* get_java_home()    { return _java_home->value(); }
 739   static char* get_dll_dir()      { return _sun_boot_library_path->value(); }
 740   static char* get_ext_dirs()     { return _ext_dirs;  }
 741   static char* get_appclasspath() { return _java_class_path->value(); }
 742   static void  fix_appclasspath();
 743 
 744 
 745   // Operation modi
 746   static Mode mode()                        { return _mode; }
 747   static bool is_interpreter_only() { return mode() == _int; }
 748 
 749 
 750   // Utility: copies src into buf, replacing "%%" with "%" and "%p" with pid.
 751   static bool copy_expand_pid(const char* src, size_t srclen, char* buf, size_t buflen);
 752 
 753   static void check_unsupported_dumping_properties() NOT_CDS_RETURN;
 754 
 755   static bool atojulong(const char *s, julong* result);
 756 };
 757 
 758 // Disable options not supported in this release, with a warning if they
 759 // were explicitly requested on the command-line
 760 #define UNSUPPORTED_OPTION(opt)                          \
 761 do {                                                     \
 762   if (opt) {                                             \
 763     if (FLAG_IS_CMDLINE(opt)) {                          \
 764       warning("-XX:+" #opt " not supported in this VM"); \
 765     }                                                    \
 766     FLAG_SET_DEFAULT(opt, false);                        \
 767   }                                                      \
 768 } while(0)
 769 
 770 #endif // SHARE_VM_RUNTIME_ARGUMENTS_HPP