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