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