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