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
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.
|
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 // Obsolete or deprecated -XX flag.
45 struct SpecialFlag {
46 const char* name;
47 JDK_Version deprecated_in; // When the deprecation warning started (or "undefined").
48 JDK_Version obsolete_in; // When the obsolete warning started (or "undefined").
49 JDK_Version expired_in; // When the option expires (or "undefined").
50 };
51
52 // PathString is used as:
53 // - the underlying value for a SystemProperty
54 // - the path portion of an --patch-module module/path pair
55 // - the string that represents the system boot class path, Arguments::_system_boot_class_path.
56 class PathString : public CHeapObj<mtArguments> {
57 protected:
58 char* _value;
59 public:
60 char* value() const { return _value; }
61
62 bool set_value(const char *value) {
63 if (_value != NULL) {
64 FreeHeap(_value);
65 }
66 _value = AllocateHeap(strlen(value)+1, mtArguments);
67 assert(_value != NULL, "Unable to allocate space for new path value");
68 if (_value != NULL) {
69 strcpy(_value, value);
70 } else {
71 // not able to allocate
509 static void process_java_launcher_argument(const char*, void*);
510 static void process_java_compiler_argument(const char* arg);
511 static jint parse_options_environment_variable(const char* name, ScopedVMInitArgs* vm_args);
512 static jint parse_java_tool_options_environment_variable(ScopedVMInitArgs* vm_args);
513 static jint parse_java_options_environment_variable(ScopedVMInitArgs* vm_args);
514 static jint parse_vm_options_file(const char* file_name, ScopedVMInitArgs* vm_args);
515 static jint parse_options_buffer(const char* name, char* buffer, const size_t buf_len, ScopedVMInitArgs* vm_args);
516 static jint insert_vm_options_file(const JavaVMInitArgs* args,
517 const char* vm_options_file,
518 const int vm_options_file_pos,
519 ScopedVMInitArgs* vm_options_file_args,
520 ScopedVMInitArgs* args_out);
521 static bool args_contains_vm_options_file_arg(const JavaVMInitArgs* args);
522 static jint expand_vm_options_as_needed(const JavaVMInitArgs* args_in,
523 ScopedVMInitArgs* mod_args,
524 JavaVMInitArgs** args_out);
525 static jint match_special_option_and_act(const JavaVMInitArgs* args,
526 ScopedVMInitArgs* args_out);
527
528 static bool handle_deprecated_print_gc_flags();
529
530 static void handle_extra_cms_flags(const char* msg);
531
532 static jint parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args,
533 const JavaVMInitArgs *java_options_args,
534 const JavaVMInitArgs *cmd_line_args);
535 static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, Flag::Flags origin);
536 static jint finalize_vm_init_args();
537 static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type);
538
539 static bool is_bad_option(const JavaVMOption* option, jboolean ignore) {
540 return is_bad_option(option, ignore, NULL);
541 }
542
543 static void describe_range_error(ArgsRange errcode);
544 static ArgsRange check_memory_size(julong size, julong min_size);
545 static ArgsRange parse_memory_size(const char* s, julong* long_arg,
546 julong min_size);
547 // Parse a string for a unsigned integer. Returns true if value
548 // is an unsigned integer greater than or equal to the minimum
549 // parameter passed and returns the value in uintx_arg. Returns
550 // false otherwise, with uintx_arg undefined.
|