annotate src/hotspot/share/runtime/arguments.hpp @ 51310:8c0a5b51559b

8203030: Zero s390 31 bit size_t type conflicts in shared code Summary: Cast to size_t or change to size_t foe compatibility with other archs. Reviewed-by: pliden, dholmes
author chrisphi
date Tue, 19 Jun 2018 10:00:39 -0400
parents e5d741569070
children 57862a02bf4b
rev   line source
duke@1 1 /*
coleenp@49829 2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation.
duke@1 8 *
duke@1 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 13 * accompanied this code).
duke@1 14 *
duke@1 15 * You should have received a copy of the GNU General Public License version
duke@1 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 18 *
trims@5547 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@5547 20 * or visit www.oracle.com if you need additional information or have any
trims@5547 21 * questions.
duke@1 22 *
duke@1 23 */
duke@1 24
stefank@7397 25 #ifndef SHARE_VM_RUNTIME_ARGUMENTS_HPP
stefank@7397 26 #define SHARE_VM_RUNTIME_ARGUMENTS_HPP
stefank@7397 27
mockner@35489 28 #include "logging/logLevel.hpp"
mockner@35489 29 #include "logging/logTag.hpp"
stefank@48373 30 #include "memory/allocation.hpp"
gziemski@50413 31 #include "runtime/flags/jvmFlag.hpp"
stefank@7397 32 #include "runtime/java.hpp"
goetz@25468 33 #include "runtime/os.hpp"
stefank@7397 34 #include "runtime/perfData.hpp"
jwilhelm@22555 35 #include "utilities/debug.hpp"
stefank@7397 36
duke@1 37 // Arguments parses the command line and recognizes options
duke@1 38
duke@1 39 // Invocation API hook typedefs (these should really be defined in jni.hpp)
duke@1 40 extern "C" {
duke@1 41 typedef void (JNICALL *abort_hook_t)(void);
duke@1 42 typedef void (JNICALL *exit_hook_t)(jint code);
drchase@24424 43 typedef jint (JNICALL *vfprintf_hook_t)(FILE *fp, const char *format, va_list args) ATTRIBUTE_PRINTF(2, 0);
duke@1 44 }
duke@1 45
jmasa@41708 46 // Obsolete or deprecated -XX flag.
jmasa@41708 47 struct SpecialFlag {
jmasa@41708 48 const char* name;
jmasa@41708 49 JDK_Version deprecated_in; // When the deprecation warning started (or "undefined").
jmasa@41708 50 JDK_Version obsolete_in; // When the obsolete warning started (or "undefined").
jmasa@41708 51 JDK_Version expired_in; // When the option expires (or "undefined").
jmasa@41708 52 };
jmasa@41708 53
alanb@37773 54 // PathString is used as:
alanb@37773 55 // - the underlying value for a SystemProperty
hseigel@40244 56 // - the path portion of an --patch-module module/path pair
alanb@37773 57 // - the string that represents the system boot class path, Arguments::_system_boot_class_path.
gziemski@37491 58 class PathString : public CHeapObj<mtArguments> {
alanb@36508 59 protected:
alanb@37773 60 char* _value;
alanb@36508 61 public:
alanb@37773 62 char* value() const { return _value; }
duke@1 63
stefank@48373 64 bool set_value(const char *value);
stefank@48373 65 void append_value(const char *value);
duke@1 66
stefank@48373 67 PathString(const char* value);
stefank@48373 68 ~PathString();
alanb@37773 69 };
alanb@37773 70
hseigel@40244 71 // ModulePatchPath records the module/path pair as specified to --patch-module.
hseigel@40244 72 class ModulePatchPath : public CHeapObj<mtInternal> {
alanb@37773 73 private:
alanb@37773 74 char* _module_name;
alanb@37773 75 PathString* _path;
alanb@37773 76 public:
stefank@48373 77 ModulePatchPath(const char* module_name, const char* path);
stefank@48373 78 ~ModulePatchPath();
alanb@37773 79
alanb@37773 80 inline void set_path(const char* path) { _path->set_value(path); }
alanb@37773 81 inline const char* module_name() const { return _module_name; }
alanb@37773 82 inline char* path_string() const { return _path->value(); }
alanb@36508 83 };
alanb@36508 84
alanb@36508 85 // Element describing System and User (-Dkey=value flags) defined property.
alanb@36508 86 //
alanb@36508 87 // An internal SystemProperty is one that has been removed in
alanb@36508 88 // jdk.internal.VM.saveAndRemoveProperties, like jdk.boot.class.path.append.
alanb@36508 89 //
alanb@36508 90 class SystemProperty : public PathString {
alanb@36508 91 private:
alanb@36508 92 char* _key;
alanb@36508 93 SystemProperty* _next;
alanb@36508 94 bool _internal;
alanb@36508 95 bool _writeable;
alanb@37773 96 bool writeable() { return _writeable; }
alanb@36508 97
alanb@36508 98 public:
alanb@36508 99 // Accessors
alanb@36508 100 char* value() const { return PathString::value(); }
alanb@36508 101 const char* key() const { return _key; }
alanb@36508 102 bool internal() const { return _internal; }
alanb@36508 103 SystemProperty* next() const { return _next; }
alanb@36508 104 void set_next(SystemProperty* next) { _next = next; }
alanb@36508 105
hseigel@40244 106 bool is_readable() const {
hseigel@40244 107 return !_internal || strcmp(_key, "jdk.boot.class.path.append") == 0;
hseigel@40244 108 }
hseigel@40244 109
alanb@36508 110 // A system property should only have its value set
alanb@36508 111 // via an external interface if it is a writeable property.
alanb@36508 112 // The internal, non-writeable property jdk.boot.class.path.append
alanb@36508 113 // is the only exception to this rule. It can be set externally
alanb@36508 114 // via -Xbootclasspath/a or JVMTI OnLoad phase call to AddToBootstrapClassLoaderSearch.
alanb@36508 115 // In those cases for jdk.boot.class.path.append, the base class
alanb@36508 116 // set_value and append_value methods are called directly.
alanb@36508 117 bool set_writeable_value(const char *value) {
alanb@36508 118 if (writeable()) {
alanb@36508 119 return set_value(value);
alanb@36508 120 }
alanb@36508 121 return false;
alanb@36508 122 }
alanb@36508 123
alanb@36508 124 // Constructor
stefank@48373 125 SystemProperty(const char* key, const char* value, bool writeable, bool internal = false);
duke@1 126 };
duke@1 127
duke@1 128
duke@1 129 // For use by -agentlib, -agentpath and -Xrun
gziemski@37491 130 class AgentLibrary : public CHeapObj<mtArguments> {
duke@1 131 friend class AgentLibraryList;
bpittore@19553 132 public:
bpittore@19553 133 // Is this library valid or not. Don't rely on os_lib == NULL as statically
bpittore@19553 134 // linked lib could have handle of RTLD_DEFAULT which == 0 on some platforms
bpittore@19553 135 enum AgentState {
bpittore@19553 136 agent_invalid = 0,
bpittore@19553 137 agent_valid = 1
bpittore@19553 138 };
bpittore@19553 139
duke@1 140 private:
duke@1 141 char* _name;
duke@1 142 char* _options;
duke@1 143 void* _os_lib;
duke@1 144 bool _is_absolute_path;
bpittore@19553 145 bool _is_static_lib;
gadams@48777 146 bool _is_instrument_lib;
bpittore@19553 147 AgentState _state;
duke@1 148 AgentLibrary* _next;
duke@1 149
duke@1 150 public:
duke@1 151 // Accessors
duke@1 152 const char* name() const { return _name; }
duke@1 153 char* options() const { return _options; }
duke@1 154 bool is_absolute_path() const { return _is_absolute_path; }
duke@1 155 void* os_lib() const { return _os_lib; }
duke@1 156 void set_os_lib(void* os_lib) { _os_lib = os_lib; }
duke@1 157 AgentLibrary* next() const { return _next; }
bpittore@19553 158 bool is_static_lib() const { return _is_static_lib; }
gadams@48777 159 bool is_instrument_lib() const { return _is_instrument_lib; }
bpittore@19973 160 void set_static_lib(bool is_static_lib) { _is_static_lib = is_static_lib; }
bpittore@19553 161 bool valid() { return (_state == agent_valid); }
bpittore@19553 162 void set_valid() { _state = agent_valid; }
bpittore@19553 163 void set_invalid() { _state = agent_invalid; }
duke@1 164
duke@1 165 // Constructor
gadams@48777 166 AgentLibrary(const char* name, const char* options, bool is_absolute_path,
gadams@48777 167 void* os_lib, bool instrument_lib=false);
duke@1 168 };
duke@1 169
duke@1 170 // maintain an order of entry list of AgentLibrary
coleenp@49829 171 class AgentLibraryList {
duke@1 172 private:
duke@1 173 AgentLibrary* _first;
duke@1 174 AgentLibrary* _last;
duke@1 175 public:
duke@1 176 bool is_empty() const { return _first == NULL; }
duke@1 177 AgentLibrary* first() const { return _first; }
duke@1 178
duke@1 179 // add to the end of the list
duke@1 180 void add(AgentLibrary* lib) {
duke@1 181 if (is_empty()) {
duke@1 182 _first = _last = lib;
duke@1 183 } else {
duke@1 184 _last->_next = lib;
duke@1 185 _last = lib;
duke@1 186 }
duke@1 187 lib->_next = NULL;
duke@1 188 }
duke@1 189
duke@1 190 // search for and remove a library known to be in the list
duke@1 191 void remove(AgentLibrary* lib) {
duke@1 192 AgentLibrary* curr;
duke@1 193 AgentLibrary* prev = NULL;
duke@1 194 for (curr = first(); curr != NULL; prev = curr, curr = curr->next()) {
duke@1 195 if (curr == lib) {
duke@1 196 break;
duke@1 197 }
duke@1 198 }
duke@1 199 assert(curr != NULL, "always should be found");
duke@1 200
duke@1 201 if (curr != NULL) {
duke@1 202 // it was found, by-pass this library
duke@1 203 if (prev == NULL) {
duke@1 204 _first = curr->_next;
duke@1 205 } else {
duke@1 206 prev->_next = curr->_next;
duke@1 207 }
duke@1 208 if (curr == _last) {
duke@1 209 _last = prev;
duke@1 210 }
duke@1 211 curr->_next = NULL;
duke@1 212 }
duke@1 213 }
duke@1 214
duke@1 215 AgentLibraryList() {
duke@1 216 _first = NULL;
duke@1 217 _last = NULL;
duke@1 218 }
duke@1 219 };
duke@1 220
jmanson@31853 221 // Helper class for controlling the lifetime of JavaVMInitArgs objects.
jmanson@31853 222 class ScopedVMInitArgs;
duke@1 223
mockner@35489 224 // Most logging functions require 5 tags. Some of them may be _NO_TAG.
mockner@35489 225 typedef struct {
mockner@35489 226 const char* alias_name;
mockner@35489 227 LogLevelType level;
mockner@35489 228 bool exactMatch;
mockner@37094 229 LogTagType tag0;
mockner@37094 230 LogTagType tag1;
mockner@37094 231 LogTagType tag2;
mockner@37094 232 LogTagType tag3;
mockner@37094 233 LogTagType tag4;
mockner@37094 234 LogTagType tag5;
mockner@35489 235 } AliasedLoggingFlag;
mockner@35489 236
duke@1 237 class Arguments : AllStatic {
duke@1 238 friend class VMStructs;
duke@1 239 friend class JvmtiExport;
bdelsart@31620 240 friend class CodeCacheExtensions;
stefank@46616 241 friend class ArgumentsTest;
duke@1 242 public:
duke@1 243 // Operation modi
duke@1 244 enum Mode {
duke@1 245 _int, // corresponds to -Xint
duke@1 246 _mixed, // corresponds to -Xmixed
duke@1 247 _comp // corresponds to -Xcomp
duke@1 248 };
duke@1 249
duke@1 250 enum ArgsRange {
duke@1 251 arg_unreadable = -3,
duke@1 252 arg_too_small = -2,
duke@1 253 arg_too_big = -1,
duke@1 254 arg_in_range = 0
duke@1 255 };
duke@1 256
hseigel@40244 257 enum PropertyAppendable {
hseigel@40244 258 AppendProperty,
hseigel@40244 259 AddProperty
hseigel@40244 260 };
hseigel@40244 261
hseigel@40244 262 enum PropertyWriteable {
hseigel@40244 263 WriteableProperty,
hseigel@40244 264 UnwriteableProperty
hseigel@40244 265 };
hseigel@40244 266
hseigel@40244 267 enum PropertyInternal {
hseigel@40244 268 InternalProperty,
hseigel@40244 269 ExternalProperty
hseigel@40244 270 };
hseigel@40244 271
duke@1 272 private:
duke@1 273
rdurbin@34125 274 // a pointer to the flags file name if it is specified
rdurbin@34125 275 static char* _jvm_flags_file;
duke@1 276 // an array containing all flags specified in the .hotspotrc file
duke@1 277 static char** _jvm_flags_array;
duke@1 278 static int _num_jvm_flags;
duke@1 279 // an array containing all jvm arguments specified in the command line
duke@1 280 static char** _jvm_args_array;
duke@1 281 static int _num_jvm_args;
duke@1 282 // string containing all java command (class/jarfile name and app args)
duke@1 283 static char* _java_command;
duke@1 284
duke@1 285 // Property list
duke@1 286 static SystemProperty* _system_properties;
duke@1 287
duke@1 288 // Quick accessor to System properties in the list:
duke@1 289 static SystemProperty *_sun_boot_library_path;
duke@1 290 static SystemProperty *_java_library_path;
duke@1 291 static SystemProperty *_java_home;
duke@1 292 static SystemProperty *_java_class_path;
alanb@36508 293 static SystemProperty *_jdk_boot_class_path_append;
dholmes@51170 294 static SystemProperty *_vm_info;
alanb@36508 295
hseigel@40244 296 // --patch-module=module=<file>(<pathsep><file>)*
alanb@37773 297 // Each element contains the associated module name, path
hseigel@40244 298 // string pair as specified to --patch-module.
hseigel@40244 299 static GrowableArray<ModulePatchPath*>* _patch_mod_prefix;
alanb@37773 300
alanb@36508 301 // The constructed value of the system class path after
alanb@36508 302 // argument processing and JVMTI OnLoad additions via
alanb@36508 303 // calls to AddToBootstrapClassLoaderSearch. This is the
alanb@36508 304 // final form before ClassLoader::setup_bootstrap_search().
hseigel@40244 305 // Note: since --patch-module is a module name/path pair, the
hseigel@40244 306 // system boot class path string no longer contains the "prefix"
hseigel@40244 307 // to the boot class path base piece as it did when
alanb@37773 308 // -Xbootclasspath/p was supported.
alanb@36508 309 static PathString *_system_boot_class_path;
duke@1 310
lfoltan@40013 311 // Set if a modular java runtime image is present vs. a build with exploded modules
lfoltan@40013 312 static bool _has_jimage;
lfoltan@40013 313
chegar@27562 314 // temporary: to emit warning if the default ext dirs are not empty.
chegar@27562 315 // remove this variable when the warning is no longer needed.
chegar@27562 316 static char* _ext_dirs;
chegar@27562 317
duke@1 318 // java.vendor.url.bug, bug reporting URL for fatal errors.
duke@1 319 static const char* _java_vendor_url_bug;
duke@1 320
duke@1 321 // sun.java.launcher, private property to provide information about
rdurbin@22734 322 // java launcher
duke@1 323 static const char* _sun_java_launcher;
duke@1 324
duke@1 325 // sun.java.launcher.pid, private property
duke@1 326 static int _sun_java_launcher_pid;
duke@1 327
rdurbin@22734 328 // was this VM created via the -XXaltjvm=<path> option
rdurbin@22734 329 static bool _sun_java_launcher_is_altjvm;
sla@8476 330
duke@1 331 // Option flags
brutisso@35872 332 static const char* _gc_log_filename;
tschatzl@19986 333 // Value of the conservative maximum heap alignment needed
tschatzl@19986 334 static size_t _conservative_max_heap_alignment;
tschatzl@19986 335
chrisphi@51310 336 static size_t _min_heap_size;
jwilhelm@26824 337
duke@1 338 // -Xrun arguments
duke@1 339 static AgentLibraryList _libraryList;
stefank@48373 340 static void add_init_library(const char* name, char* options);
duke@1 341
duke@1 342 // -agentlib and -agentpath arguments
duke@1 343 static AgentLibraryList _agentList;
stefank@48373 344 static void add_init_agent(const char* name, char* options, bool absolute_path);
gadams@48777 345 static void add_instrument_agent(const char* name, char* options, bool absolute_path);
duke@1 346
duke@1 347 // Late-binding agents not started via arguments
stefank@48373 348 static void add_loaded_agent(AgentLibrary *agentLib);
stefank@48373 349 static void add_loaded_agent(const char* name, char* options, bool absolute_path, void* os_lib);
duke@1 350
duke@1 351 // Operation modi
duke@1 352 static Mode _mode;
duke@1 353 static void set_mode_flags(Mode mode);
duke@1 354 static bool _java_compiler;
duke@1 355 static void set_java_compiler(bool arg) { _java_compiler = arg; }
duke@1 356 static bool java_compiler() { return _java_compiler; }
duke@1 357
duke@1 358 // -Xdebug flag
duke@1 359 static bool _xdebug_mode;
duke@1 360 static void set_xdebug_mode(bool arg) { _xdebug_mode = arg; }
duke@1 361 static bool xdebug_mode() { return _xdebug_mode; }
duke@1 362
hseigel@50211 363 // preview features
hseigel@50211 364 static bool _enable_preview;
hseigel@50211 365
duke@1 366 // Used to save default settings
duke@1 367 static bool _AlwaysCompileLoopMethods;
duke@1 368 static bool _UseOnStackReplacement;
duke@1 369 static bool _BackgroundCompilation;
duke@1 370 static bool _ClipInlining;
duke@1 371 static bool _CIDynamicCompilePriority;
roland@30201 372 static intx _Tier3InvokeNotifyFreqLog;
roland@30201 373 static intx _Tier4InvocationThreshold;
duke@1 374
duke@1 375 // GC ergonomics
tschatzl@19986 376 static void set_conservative_max_heap_alignment();
brutisso@15957 377 static void set_use_compressed_oops();
hseigel@19319 378 static void set_use_compressed_klass_ptrs();
rkennke@48089 379 static jint set_ergonomics_flags();
jcoomes@8681 380 static void set_shared_spaces_flags();
tschatzl@16605 381 // limits the given memory size by the maximum amount of memory this process is
tschatzl@16605 382 // currently allowed to allocate or reserve.
tschatzl@16605 383 static julong limit_by_allocatable_memory(julong size);
phh@4434 384 // Setup heap size
phh@4434 385 static void set_heap_size();
duke@1 386
duke@1 387 // Bytecode rewriting
duke@1 388 static void set_bytecode_flags();
duke@1 389
duke@1 390 // Invocation API hooks
duke@1 391 static abort_hook_t _abort_hook;
duke@1 392 static exit_hook_t _exit_hook;
duke@1 393 static vfprintf_hook_t _vfprintf_hook;
duke@1 394
duke@1 395 // System properties
hseigel@40244 396 static bool add_property(const char* prop, PropertyWriteable writeable=WriteableProperty,
hseigel@40244 397 PropertyInternal internal=ExternalProperty);
hseigel@40244 398
hseigel@40244 399 static bool create_property(const char* prop_name, const char* prop_value, PropertyInternal internal);
hseigel@40244 400 static bool create_numbered_property(const char* prop_base_name, const char* prop_value, unsigned int count);
hseigel@40244 401
hseigel@40244 402 static int process_patch_mod_option(const char* patch_mod_tail, bool* patch_mod_javabase);
duke@1 403
duke@1 404 // Aggressive optimization flags.
ddmitriev@32595 405 static jint set_aggressive_opts_flags();
duke@1 406
drwhite@32823 407 static jint set_aggressive_heap_flags();
drwhite@32823 408
duke@1 409 // Argument parsing
duke@1 410 static void do_pd_flag_adjustments();
gziemski@50413 411 static bool parse_argument(const char* arg, JVMFlag::Flags origin);
gziemski@50413 412 static bool process_argument(const char* arg, jboolean ignore_unrecognized, JVMFlag::Flags origin);
duke@1 413 static void process_java_launcher_argument(const char*, void*);
ddmitriev@32595 414 static void process_java_compiler_argument(const char* arg);
jmanson@31853 415 static jint parse_options_environment_variable(const char* name, ScopedVMInitArgs* vm_args);
jmanson@31853 416 static jint parse_java_tool_options_environment_variable(ScopedVMInitArgs* vm_args);
jmanson@31853 417 static jint parse_java_options_environment_variable(ScopedVMInitArgs* vm_args);
rdurbin@32621 418 static jint parse_vm_options_file(const char* file_name, ScopedVMInitArgs* vm_args);
rdurbin@32621 419 static jint parse_options_buffer(const char* name, char* buffer, const size_t buf_len, ScopedVMInitArgs* vm_args);
stefank@46616 420 static jint parse_xss(const JavaVMOption* option, const char* tail, intx* out_ThreadStackSize);
rdurbin@32621 421 static jint insert_vm_options_file(const JavaVMInitArgs* args,
rdurbin@35466 422 const char* vm_options_file,
rdurbin@32621 423 const int vm_options_file_pos,
rdurbin@32621 424 ScopedVMInitArgs* vm_options_file_args,
rdurbin@32621 425 ScopedVMInitArgs* args_out);
rdurbin@35466 426 static bool args_contains_vm_options_file_arg(const JavaVMInitArgs* args);
rdurbin@35466 427 static jint expand_vm_options_as_needed(const JavaVMInitArgs* args_in,
rdurbin@35466 428 ScopedVMInitArgs* mod_args,
rdurbin@35466 429 JavaVMInitArgs** args_out);
rdurbin@32621 430 static jint match_special_option_and_act(const JavaVMInitArgs* args,
rdurbin@32621 431 ScopedVMInitArgs* args_out);
rdurbin@32621 432
brutisso@35872 433 static bool handle_deprecated_print_gc_flags();
brutisso@35872 434
jmasa@41708 435 static void handle_extra_cms_flags(const char* msg);
jmasa@41708 436
jmanson@31853 437 static jint parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args,
jmanson@31853 438 const JavaVMInitArgs *java_options_args,
jmanson@31853 439 const JavaVMInitArgs *cmd_line_args);
gziemski@50413 440 static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, JVMFlag::Flags origin);
ccheung@47103 441 static jint finalize_vm_init_args(bool patch_mod_javabase);
jwilhelm@22555 442 static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type);
jwilhelm@22555 443
duke@1 444 static bool is_bad_option(const JavaVMOption* option, jboolean ignore) {
duke@1 445 return is_bad_option(option, ignore, NULL);
duke@1 446 }
jwilhelm@22555 447
duke@1 448 static void describe_range_error(ArgsRange errcode);
stefank@46616 449 static ArgsRange check_memory_size(julong size, julong min_size, julong max_size);
swamyv@1676 450 static ArgsRange parse_memory_size(const char* s, julong* long_arg,
stefank@46616 451 julong min_size, julong max_size = max_uintx);
jmasa@5035 452 // Parse a string for a unsigned integer. Returns true if value
jmasa@5035 453 // is an unsigned integer greater than or equal to the minimum
jmasa@5035 454 // parameter passed and returns the value in uintx_arg. Returns
jmasa@5035 455 // false otherwise, with uintx_arg undefined.
jmasa@5035 456 static bool parse_uintx(const char* value, uintx* uintx_arg,
jmasa@5035 457 uintx min_size);
duke@1 458
duke@1 459 // methods to build strings from individual args
duke@1 460 static void build_jvm_args(const char* arg);
duke@1 461 static void build_jvm_flags(const char* arg);
duke@1 462 static void add_string(char*** bldarray, int* count, const char* arg);
duke@1 463 static const char* build_resource_string(char** args, int count);
duke@1 464
drwhite@32823 465 // Returns true if the flag is obsolete (and not yet expired).
drwhite@32823 466 // In this case the 'version' buffer is filled in with
drwhite@32823 467 // the version number when the flag became obsolete.
drwhite@32823 468 static bool is_obsolete_flag(const char* flag_name, JDK_Version* version);
drwhite@32823 469
mockner@37173 470 #ifndef PRODUCT
mockner@37173 471 static const char* removed_develop_logging_flag_name(const char* name);
mockner@37173 472 #endif // PRODUCT
mockner@37173 473
drwhite@32823 474 // Returns 1 if the flag is deprecated (and not yet obsolete or expired).
drwhite@32823 475 // In this case the 'version' buffer is filled in with the version number when
drwhite@32823 476 // the flag became deprecated.
drwhite@32823 477 // Returns -1 if the flag is expired or obsolete.
drwhite@32823 478 // Returns 0 otherwise.
drwhite@32823 479 static int is_deprecated_flag(const char* flag_name, JDK_Version* version);
drwhite@32823 480
drwhite@32823 481 // Return the real name for the flag passed on the command line (either an alias name or "flag_name").
drwhite@32823 482 static const char* real_flag_name(const char *flag_name);
drwhite@32823 483
drwhite@32823 484 // Return the "real" name for option arg if arg is an alias, and print a warning if arg is deprecated.
drwhite@32823 485 // Return NULL if the arg has expired.
drwhite@32823 486 static const char* handle_aliases_and_deprecation(const char* arg, bool warn);
rprotacio@35171 487 static bool lookup_logging_aliases(const char* arg, char* buffer);
rprotacio@37216 488 static AliasedLoggingFlag catch_logging_aliases(const char* name, bool on);
duke@1 489
duke@1 490 static char* SharedArchivePath;
duke@1 491
duke@1 492 public:
tschatzl@19986 493 // Parses the arguments, first phase
duke@1 494 static jint parse(const JavaVMInitArgs* args);
tschatzl@19986 495 // Apply ergonomics
tschatzl@19986 496 static jint apply_ergo();
brutisso@14580 497 // Adjusts the arguments after the OS have adjusted the arguments
brutisso@14580 498 static jint adjust_after_os();
jwilhelm@22555 499
jmasa@183 500 // Check for consistency in the selection of the garbage collector.
sjohanss@29696 501 static bool check_gc_consistency(); // Check user-selected gc
jwilhelm@22551 502 // Check consistency or otherwise of VM argument settings
duke@1 503 static bool check_vm_args_consistency();
duke@1 504 // Used by os_solaris
duke@1 505 static bool process_settings_file(const char* file_name, bool should_exist, jboolean ignore_unrecognized);
duke@1 506
tschatzl@19986 507 static size_t conservative_max_heap_alignment() { return _conservative_max_heap_alignment; }
tschatzl@19986 508 // Return the maximum size a heap with compressed oops can take
tschatzl@19986 509 static size_t max_heap_for_compressed_oops();
tschatzl@19986 510
duke@1 511 // return a char* array containing all options
duke@1 512 static char** jvm_flags_array() { return _jvm_flags_array; }
duke@1 513 static char** jvm_args_array() { return _jvm_args_array; }
duke@1 514 static int num_jvm_flags() { return _num_jvm_flags; }
duke@1 515 static int num_jvm_args() { return _num_jvm_args; }
duke@1 516 // return the arguments passed to the Java application
duke@1 517 static const char* java_command() { return _java_command; }
duke@1 518
duke@1 519 // print jvm_flags, jvm_args and java_command
duke@1 520 static void print_on(outputStream* st);
coleenp@31963 521 static void print_summary_on(outputStream* st);
duke@1 522
rdurbin@34125 523 // convenient methods to get and set jvm_flags_file
rdurbin@34125 524 static const char* get_jvm_flags_file() { return _jvm_flags_file; }
rdurbin@34125 525 static void set_jvm_flags_file(const char *value) {
rdurbin@34125 526 if (_jvm_flags_file != NULL) {
rdurbin@34125 527 os::free(_jvm_flags_file);
rdurbin@34125 528 }
rdurbin@34125 529 _jvm_flags_file = os::strdup_check_oom(value);
rdurbin@34125 530 }
duke@1 531 // convenient methods to obtain / print jvm_flags and jvm_args
duke@1 532 static const char* jvm_flags() { return build_resource_string(_jvm_flags_array, _num_jvm_flags); }
duke@1 533 static const char* jvm_args() { return build_resource_string(_jvm_args_array, _num_jvm_args); }
duke@1 534 static void print_jvm_flags_on(outputStream* st);
duke@1 535 static void print_jvm_args_on(outputStream* st);
duke@1 536
duke@1 537 // -Dkey=value flags
duke@1 538 static SystemProperty* system_properties() { return _system_properties; }
duke@1 539 static const char* get_property(const char* key);
duke@1 540
duke@1 541 // -Djava.vendor.url.bug
duke@1 542 static const char* java_vendor_url_bug() { return _java_vendor_url_bug; }
duke@1 543
duke@1 544 // -Dsun.java.launcher
duke@1 545 static const char* sun_java_launcher() { return _sun_java_launcher; }
duke@1 546 // Was VM created by a Java launcher?
duke@1 547 static bool created_by_java_launcher();
rdurbin@22734 548 // -Dsun.java.launcher.is_altjvm
rdurbin@22734 549 static bool sun_java_launcher_is_altjvm();
duke@1 550 // -Dsun.java.launcher.pid
duke@1 551 static int sun_java_launcher_pid() { return _sun_java_launcher_pid; }
duke@1 552
jwilhelm@22551 553 // -Xms
jwilhelm@29697 554 static size_t min_heap_size() { return _min_heap_size; }
jwilhelm@29697 555 static void set_min_heap_size(size_t v) { _min_heap_size = v; }
duke@1 556
duke@1 557 // -Xrun
duke@1 558 static AgentLibrary* libraries() { return _libraryList.first(); }
duke@1 559 static bool init_libraries_at_startup() { return !_libraryList.is_empty(); }
duke@1 560 static void convert_library_to_agent(AgentLibrary* lib)
duke@1 561 { _libraryList.remove(lib);
duke@1 562 _agentList.add(lib); }
duke@1 563
duke@1 564 // -agentlib -agentpath
duke@1 565 static AgentLibrary* agents() { return _agentList.first(); }
duke@1 566 static bool init_agents_at_startup() { return !_agentList.is_empty(); }
duke@1 567
duke@1 568 // abort, exit, vfprintf hooks
duke@1 569 static abort_hook_t abort_hook() { return _abort_hook; }
duke@1 570 static exit_hook_t exit_hook() { return _exit_hook; }
duke@1 571 static vfprintf_hook_t vfprintf_hook() { return _vfprintf_hook; }
duke@1 572
duke@1 573 static const char* GetSharedArchivePath() { return SharedArchivePath; }
duke@1 574
duke@1 575 // Java launcher properties
duke@1 576 static void process_sun_java_launcher_properties(JavaVMInitArgs* args);
duke@1 577
duke@1 578 // System properties
duke@1 579 static void init_system_properties();
duke@1 580
zgu@6961 581 // Update/Initialize System properties after JDK version number is known
zgu@6961 582 static void init_version_specific_system_properties();
zgu@6961 583
dholmes@51170 584 // Update VM info property - called after argument parsing
dholmes@51170 585 static void update_vm_info_property(const char* vm_info) {
dholmes@51170 586 _vm_info->set_value(vm_info);
dholmes@51170 587 }
dholmes@51170 588
phh@2358 589 // Property List manipulation
goetz@28372 590 static void PropertyList_add(SystemProperty *element);
duke@1 591 static void PropertyList_add(SystemProperty** plist, SystemProperty *element);
hseigel@40244 592 static void PropertyList_add(SystemProperty** plist, const char* k, const char* v, bool writeable, bool internal);
hseigel@40244 593
hseigel@40244 594 static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v,
hseigel@40244 595 PropertyAppendable append, PropertyWriteable writeable,
hseigel@40244 596 PropertyInternal internal);
duke@1 597 static const char* PropertyList_get_value(SystemProperty* plist, const char* key);
hseigel@40244 598 static const char* PropertyList_get_readable_value(SystemProperty* plist, const char* key);
duke@1 599 static int PropertyList_count(SystemProperty* pl);
hseigel@40244 600 static int PropertyList_readable_count(SystemProperty* pl);
duke@1 601 static const char* PropertyList_get_key_at(SystemProperty* pl,int index);
duke@1 602 static char* PropertyList_get_value_at(SystemProperty* pl,int index);
duke@1 603
hseigel@40244 604 static bool is_internal_module_property(const char* option);
hseigel@40244 605
duke@1 606 // Miscellaneous System property value getter and setters.
ddmitriev@32595 607 static void set_dll_dir(const char *value) { _sun_boot_library_path->set_value(value); }
ddmitriev@32595 608 static void set_java_home(const char *value) { _java_home->set_value(value); }
ddmitriev@32595 609 static void set_library_path(const char *value) { _java_library_path->set_value(value); }
chegar@27562 610 static void set_ext_dirs(char *value) { _ext_dirs = os::strdup_check_oom(value); }
alanb@36508 611
alanb@37773 612 // Set up the underlying pieces of the system boot class path
hseigel@40244 613 static void add_patch_mod_prefix(const char *module_name, const char *path, bool* patch_mod_javabase);
lfoltan@40013 614 static void set_sysclasspath(const char *value, bool has_jimage) {
lfoltan@40013 615 // During start up, set by os::set_boot_path()
lfoltan@40013 616 assert(get_sysclasspath() == NULL, "System boot class path previously set");
alanb@36508 617 _system_boot_class_path->set_value(value);
lfoltan@40013 618 _has_jimage = has_jimage;
alanb@36508 619 }
alanb@36508 620 static void append_sysclasspath(const char *value) {
alanb@36508 621 _system_boot_class_path->append_value(value);
lfoltan@40013 622 _jdk_boot_class_path_append->append_value(value);
alanb@36508 623 }
duke@1 624
hseigel@40244 625 static GrowableArray<ModulePatchPath*>* get_patch_mod_prefix() { return _patch_mod_prefix; }
alanb@36508 626 static char* get_sysclasspath() { return _system_boot_class_path->value(); }
alanb@37773 627 static char* get_jdk_boot_class_path_append() { return _jdk_boot_class_path_append->value(); }
lfoltan@40013 628 static bool has_jimage() { return _has_jimage; }
alanb@37773 629
alanb@37773 630 static char* get_java_home() { return _java_home->value(); }
alanb@37773 631 static char* get_dll_dir() { return _sun_boot_library_path->value(); }
alanb@37773 632 static char* get_ext_dirs() { return _ext_dirs; }
iklam@26135 633 static char* get_appclasspath() { return _java_class_path->value(); }
iklam@26135 634 static void fix_appclasspath();
duke@1 635
chegar@27562 636
duke@1 637 // Operation modi
alanb@36508 638 static Mode mode() { return _mode; }
iveresov@26585 639 static bool is_interpreter_only() { return mode() == _int; }
iveresov@26585 640
hseigel@50211 641 // preview features
hseigel@50211 642 static void set_enable_preview() { _enable_preview = true; }
hseigel@50211 643 static bool enable_preview() { return _enable_preview; }
duke@1 644
duke@1 645 // Utility: copies src into buf, replacing "%%" with "%" and "%p" with pid.
duke@1 646 static bool copy_expand_pid(const char* src, size_t srclen, char* buf, size_t buflen);
alanb@36508 647
alanb@36508 648 static void check_unsupported_dumping_properties() NOT_CDS_RETURN;
ysuenaga@38195 649
stefank@50241 650 static bool check_unsupported_cds_runtime_properties() NOT_CDS_RETURN0;
ccheung@50234 651
ysuenaga@38195 652 static bool atojulong(const char *s, julong* result);
duke@1 653 };
stefank@7397 654
aharlap@28838 655 // Disable options not supported in this release, with a warning if they
aharlap@28838 656 // were explicitly requested on the command-line
pliden@37253 657 #define UNSUPPORTED_OPTION(opt) \
pliden@37253 658 do { \
pliden@37253 659 if (opt) { \
pliden@37253 660 if (FLAG_IS_CMDLINE(opt)) { \
pliden@37253 661 warning("-XX:+" #opt " not supported in this VM"); \
pliden@37253 662 } \
pliden@37253 663 FLAG_SET_DEFAULT(opt, false); \
pliden@37253 664 } \
aharlap@28838 665 } while(0)
aharlap@28838 666
stefank@7397 667 #endif // SHARE_VM_RUNTIME_ARGUMENTS_HPP