41 typedef void (JNICALL *exit_hook_t)(jint code); |
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); |
42 typedef jint (JNICALL *vfprintf_hook_t)(FILE *fp, const char *format, va_list args) ATTRIBUTE_PRINTF(2, 0); |
43 } |
43 } |
44 |
44 |
45 // Forward declarations |
45 // Forward declarations |
46 |
46 class ArgumentBootClassPath; |
47 class SysClassPath; |
47 |
48 |
48 // PathString is used as the underlying value container for a |
49 // Element describing System and User (-Dkey=value flags) defined property. |
49 // SystemProperty and for the string that represents the system |
50 |
50 // boot class path, Arguments::_system_boot_class_path. |
51 class SystemProperty: public CHeapObj<mtInternal> { |
51 class PathString : public CHeapObj<mtInternal> { |
52 private: |
52 protected: |
53 char* _key; |
|
54 char* _value; |
53 char* _value; |
55 SystemProperty* _next; |
|
56 bool _writeable; |
|
57 bool writeable() { return _writeable; } |
|
58 |
|
59 public: |
54 public: |
60 // Accessors |
|
61 const char* key() const { return _key; } |
|
62 char* value() const { return _value; } |
55 char* value() const { return _value; } |
63 SystemProperty* next() const { return _next; } |
56 |
64 void set_next(SystemProperty* next) { _next = next; } |
|
65 bool set_value(const char *value) { |
57 bool set_value(const char *value) { |
66 if (writeable()) { |
58 if (_value != NULL) { |
67 if (_value != NULL) { |
59 FreeHeap(_value); |
68 FreeHeap(_value); |
60 } |
69 } |
61 _value = AllocateHeap(strlen(value)+1, mtInternal); |
70 _value = AllocateHeap(strlen(value)+1, mtInternal); |
62 assert(_value != NULL, "Unable to allocate space for new path value"); |
71 if (_value != NULL) { |
63 if (_value != NULL) { |
72 strcpy(_value, value); |
64 strcpy(_value, value); |
73 } |
65 } else { |
74 return true; |
66 // not able to allocate |
75 } |
67 return false; |
76 return false; |
68 } |
|
69 return true; |
77 } |
70 } |
78 |
71 |
79 void append_value(const char *value) { |
72 void append_value(const char *value) { |
80 char *sp; |
73 char *sp; |
81 size_t len = 0; |
74 size_t len = 0; |
98 } |
92 } |
99 } |
93 } |
100 } |
94 } |
101 |
95 |
102 // Constructor |
96 // Constructor |
103 SystemProperty(const char* key, const char* value, bool writeable) { |
97 PathString(const char* value) { |
|
98 if (value == NULL) { |
|
99 _value = NULL; |
|
100 } else { |
|
101 _value = AllocateHeap(strlen(value)+1, mtInternal); |
|
102 strcpy(_value, value); |
|
103 } |
|
104 } |
|
105 }; |
|
106 |
|
107 // Element describing System and User (-Dkey=value flags) defined property. |
|
108 // |
|
109 // An internal SystemProperty is one that has been removed in |
|
110 // jdk.internal.VM.saveAndRemoveProperties, like jdk.boot.class.path.append. |
|
111 // |
|
112 class SystemProperty : public PathString { |
|
113 private: |
|
114 char* _key; |
|
115 SystemProperty* _next; |
|
116 bool _internal; |
|
117 bool _writeable; |
|
118 bool writeable() { return _writeable; } |
|
119 |
|
120 public: |
|
121 // Accessors |
|
122 char* value() const { return PathString::value(); } |
|
123 const char* key() const { return _key; } |
|
124 bool internal() const { return _internal; } |
|
125 SystemProperty* next() const { return _next; } |
|
126 void set_next(SystemProperty* next) { _next = next; } |
|
127 |
|
128 // A system property should only have its value set |
|
129 // via an external interface if it is a writeable property. |
|
130 // The internal, non-writeable property jdk.boot.class.path.append |
|
131 // is the only exception to this rule. It can be set externally |
|
132 // via -Xbootclasspath/a or JVMTI OnLoad phase call to AddToBootstrapClassLoaderSearch. |
|
133 // In those cases for jdk.boot.class.path.append, the base class |
|
134 // set_value and append_value methods are called directly. |
|
135 bool set_writeable_value(const char *value) { |
|
136 if (writeable()) { |
|
137 return set_value(value); |
|
138 } |
|
139 return false; |
|
140 } |
|
141 |
|
142 // Constructor |
|
143 SystemProperty(const char* key, const char* value, bool writeable, bool internal = false) : PathString(value) { |
104 if (key == NULL) { |
144 if (key == NULL) { |
105 _key = NULL; |
145 _key = NULL; |
106 } else { |
146 } else { |
107 _key = AllocateHeap(strlen(key)+1, mtInternal); |
147 _key = AllocateHeap(strlen(key)+1, mtInternal); |
108 strcpy(_key, key); |
148 strcpy(_key, key); |
109 } |
149 } |
110 if (value == NULL) { |
|
111 _value = NULL; |
|
112 } else { |
|
113 _value = AllocateHeap(strlen(value)+1, mtInternal); |
|
114 strcpy(_value, value); |
|
115 } |
|
116 _next = NULL; |
150 _next = NULL; |
|
151 _internal = internal; |
117 _writeable = writeable; |
152 _writeable = writeable; |
118 } |
153 } |
119 }; |
154 }; |
120 |
155 |
121 |
156 |
271 // Quick accessor to System properties in the list: |
306 // Quick accessor to System properties in the list: |
272 static SystemProperty *_sun_boot_library_path; |
307 static SystemProperty *_sun_boot_library_path; |
273 static SystemProperty *_java_library_path; |
308 static SystemProperty *_java_library_path; |
274 static SystemProperty *_java_home; |
309 static SystemProperty *_java_home; |
275 static SystemProperty *_java_class_path; |
310 static SystemProperty *_java_class_path; |
276 static SystemProperty *_sun_boot_class_path; |
311 static SystemProperty *_jdk_boot_class_path_append; |
|
312 |
|
313 // The constructed value of the system class path after |
|
314 // argument processing and JVMTI OnLoad additions via |
|
315 // calls to AddToBootstrapClassLoaderSearch. This is the |
|
316 // final form before ClassLoader::setup_bootstrap_search(). |
|
317 static PathString *_system_boot_class_path; |
277 |
318 |
278 // temporary: to emit warning if the default ext dirs are not empty. |
319 // temporary: to emit warning if the default ext dirs are not empty. |
279 // remove this variable when the warning is no longer needed. |
320 // remove this variable when the warning is no longer needed. |
280 static char* _ext_dirs; |
321 static char* _ext_dirs; |
281 |
322 |
296 static bool _has_profile; |
337 static bool _has_profile; |
297 static const char* _gc_log_filename; |
338 static const char* _gc_log_filename; |
298 // Value of the conservative maximum heap alignment needed |
339 // Value of the conservative maximum heap alignment needed |
299 static size_t _conservative_max_heap_alignment; |
340 static size_t _conservative_max_heap_alignment; |
300 |
341 |
301 static uintx _min_heap_size; |
342 static uintx _min_heap_size; |
302 |
343 |
303 // -Xrun arguments |
344 // -Xrun arguments |
304 static AgentLibraryList _libraryList; |
345 static AgentLibraryList _libraryList; |
305 static void add_init_library(const char* name, char* options) |
346 static void add_init_library(const char* name, char* options) |
306 { _libraryList.add(new AgentLibrary(name, options, false, NULL)); } |
347 { _libraryList.add(new AgentLibrary(name, options, false, NULL)); } |
320 static Mode _mode; |
361 static Mode _mode; |
321 static void set_mode_flags(Mode mode); |
362 static void set_mode_flags(Mode mode); |
322 static bool _java_compiler; |
363 static bool _java_compiler; |
323 static void set_java_compiler(bool arg) { _java_compiler = arg; } |
364 static void set_java_compiler(bool arg) { _java_compiler = arg; } |
324 static bool java_compiler() { return _java_compiler; } |
365 static bool java_compiler() { return _java_compiler; } |
|
366 |
|
367 // Capture the index location of -Xbootclasspath\a within sysclasspath. |
|
368 // Used when setting up the bootstrap search path in order to |
|
369 // mark the boot loader's append path observability boundary. |
|
370 static int _bootclassloader_append_index; |
|
371 |
|
372 // -Xpatch flag |
|
373 static char** _patch_dirs; |
|
374 static int _patch_dirs_count; |
|
375 static void set_patch_dirs(char** dirs) { _patch_dirs = dirs; } |
|
376 static void set_patch_dirs_count(int count) { _patch_dirs_count = count; } |
325 |
377 |
326 // -Xdebug flag |
378 // -Xdebug flag |
327 static bool _xdebug_mode; |
379 static bool _xdebug_mode; |
328 static void set_xdebug_mode(bool arg) { _xdebug_mode = arg; } |
380 static void set_xdebug_mode(bool arg) { _xdebug_mode = arg; } |
329 static bool xdebug_mode() { return _xdebug_mode; } |
381 static bool xdebug_mode() { return _xdebug_mode; } |
371 static vfprintf_hook_t _vfprintf_hook; |
423 static vfprintf_hook_t _vfprintf_hook; |
372 |
424 |
373 // System properties |
425 // System properties |
374 static bool add_property(const char* prop); |
426 static bool add_property(const char* prop); |
375 |
427 |
|
428 // Miscellaneous system property setter |
|
429 static bool append_to_addmods_property(const char* module_name); |
|
430 |
376 // Aggressive optimization flags. |
431 // Aggressive optimization flags. |
377 static jint set_aggressive_opts_flags(); |
432 static jint set_aggressive_opts_flags(); |
378 |
433 |
379 static jint set_aggressive_heap_flags(); |
434 static jint set_aggressive_heap_flags(); |
380 |
435 |
404 static bool handle_deprecated_print_gc_flags(); |
459 static bool handle_deprecated_print_gc_flags(); |
405 |
460 |
406 static jint parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args, |
461 static jint parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args, |
407 const JavaVMInitArgs *java_options_args, |
462 const JavaVMInitArgs *java_options_args, |
408 const JavaVMInitArgs *cmd_line_args); |
463 const JavaVMInitArgs *cmd_line_args); |
409 static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, SysClassPath* scp_p, bool* scp_assembly_required_p, Flag::Flags origin); |
464 static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, ArgumentBootClassPath* bcp_p, bool* bcp_assembly_required_p, Flag::Flags origin); |
410 static jint finalize_vm_init_args(SysClassPath* scp_p, bool scp_assembly_required); |
465 static jint finalize_vm_init_args(ArgumentBootClassPath* bcp_p, bool bcp_assembly_required); |
411 static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type); |
466 static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type); |
412 |
467 |
413 static bool is_bad_option(const JavaVMOption* option, jboolean ignore) { |
468 static bool is_bad_option(const JavaVMOption* option, jboolean ignore) { |
414 return is_bad_option(option, ignore, NULL); |
469 return is_bad_option(option, ignore, NULL); |
415 } |
470 } |
567 |
622 |
568 // -Xms |
623 // -Xms |
569 static size_t min_heap_size() { return _min_heap_size; } |
624 static size_t min_heap_size() { return _min_heap_size; } |
570 static void set_min_heap_size(size_t v) { _min_heap_size = v; } |
625 static void set_min_heap_size(size_t v) { _min_heap_size = v; } |
571 |
626 |
|
627 // -Xbootclasspath/a |
|
628 static int bootclassloader_append_index() { |
|
629 return _bootclassloader_append_index; |
|
630 } |
|
631 static void set_bootclassloader_append_index(int value) { |
|
632 _bootclassloader_append_index = value; |
|
633 } |
|
634 |
|
635 // -Xpatch |
|
636 static char** patch_dirs() { return _patch_dirs; } |
|
637 static int patch_dirs_count() { return _patch_dirs_count; } |
|
638 |
572 // -Xrun |
639 // -Xrun |
573 static AgentLibrary* libraries() { return _libraryList.first(); } |
640 static AgentLibrary* libraries() { return _libraryList.first(); } |
574 static bool init_libraries_at_startup() { return !_libraryList.is_empty(); } |
641 static bool init_libraries_at_startup() { return !_libraryList.is_empty(); } |
575 static void convert_library_to_agent(AgentLibrary* lib) |
642 static void convert_library_to_agent(AgentLibrary* lib) |
576 { _libraryList.remove(lib); |
643 { _libraryList.remove(lib); |
623 // Miscellaneous System property value getter and setters. |
690 // Miscellaneous System property value getter and setters. |
624 static void set_dll_dir(const char *value) { _sun_boot_library_path->set_value(value); } |
691 static void set_dll_dir(const char *value) { _sun_boot_library_path->set_value(value); } |
625 static void set_java_home(const char *value) { _java_home->set_value(value); } |
692 static void set_java_home(const char *value) { _java_home->set_value(value); } |
626 static void set_library_path(const char *value) { _java_library_path->set_value(value); } |
693 static void set_library_path(const char *value) { _java_library_path->set_value(value); } |
627 static void set_ext_dirs(char *value) { _ext_dirs = os::strdup_check_oom(value); } |
694 static void set_ext_dirs(char *value) { _ext_dirs = os::strdup_check_oom(value); } |
628 static void set_sysclasspath(const char *value) { _sun_boot_class_path->set_value(value); } |
695 |
629 static void append_sysclasspath(const char *value) { _sun_boot_class_path->append_value(value); } |
696 // Set up of the underlying system boot class path |
|
697 static void set_jdkbootclasspath_append(); |
|
698 static void set_sysclasspath(const char *value) { |
|
699 _system_boot_class_path->set_value(value); |
|
700 set_jdkbootclasspath_append(); |
|
701 } |
|
702 static void append_sysclasspath(const char *value) { |
|
703 _system_boot_class_path->append_value(value); |
|
704 set_jdkbootclasspath_append(); |
|
705 } |
630 |
706 |
631 static char* get_java_home() { return _java_home->value(); } |
707 static char* get_java_home() { return _java_home->value(); } |
632 static char* get_dll_dir() { return _sun_boot_library_path->value(); } |
708 static char* get_dll_dir() { return _sun_boot_library_path->value(); } |
633 static char* get_sysclasspath() { return _sun_boot_class_path->value(); } |
709 static char* get_sysclasspath() { return _system_boot_class_path->value(); } |
634 static char* get_ext_dirs() { return _ext_dirs; } |
710 static char* get_ext_dirs() { return _ext_dirs; } |
635 static char* get_appclasspath() { return _java_class_path->value(); } |
711 static char* get_appclasspath() { return _java_class_path->value(); } |
636 static void fix_appclasspath(); |
712 static void fix_appclasspath(); |
637 |
713 |
638 |
714 |
639 // Operation modi |
715 // Operation modi |
640 static Mode mode() { return _mode; } |
716 static Mode mode() { return _mode; } |
641 static bool is_interpreter_only() { return mode() == _int; } |
717 static bool is_interpreter_only() { return mode() == _int; } |
642 |
718 |
643 |
719 |
644 // Utility: copies src into buf, replacing "%%" with "%" and "%p" with pid. |
720 // Utility: copies src into buf, replacing "%%" with "%" and "%p" with pid. |
645 static bool copy_expand_pid(const char* src, size_t srclen, char* buf, size_t buflen); |
721 static bool copy_expand_pid(const char* src, size_t srclen, char* buf, size_t buflen); |
|
722 |
|
723 static void check_unsupported_dumping_properties() NOT_CDS_RETURN; |
646 }; |
724 }; |
647 |
725 |
648 bool Arguments::gc_selected() { |
726 bool Arguments::gc_selected() { |
649 return UseConcMarkSweepGC || UseG1GC || UseParallelGC || UseParallelOldGC || UseSerialGC; |
727 return UseConcMarkSweepGC || UseG1GC || UseParallelGC || UseParallelOldGC || UseSerialGC; |
650 } |
728 } |