1 /*
2 * Copyright (c) 1997, 2025, 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 *
73 void append_value(const char *value);
74
75 PathString(const char* value);
76 ~PathString();
77
78 // for JVM_ReadSystemPropertiesInfo
79 static int value_offset_in_bytes() { return (int)offset_of(PathString, _value); }
80 };
81
82 // ModulePatchPath records the module/path pair as specified to --patch-module.
83 class ModulePatchPath : public CHeapObj<mtInternal> {
84 private:
85 char* _module_name;
86 PathString* _path;
87 public:
88 ModulePatchPath(const char* module_name, const char* path);
89 ~ModulePatchPath();
90
91 inline const char* module_name() const { return _module_name; }
92 inline char* path_string() const { return _path->value(); }
93 };
94
95 // Element describing System and User (-Dkey=value flags) defined property.
96 //
97 // An internal SystemProperty is one that has been removed in
98 // jdk.internal.VM.saveAndRemoveProperties, like jdk.boot.class.path.append.
99 //
100 class SystemProperty : public PathString {
101 private:
102 char* _key;
103 SystemProperty* _next;
104 bool _internal;
105 bool _writeable;
106
107 public:
108 // Accessors
109 char* value() const { return PathString::value(); }
110 const char* key() const { return _key; }
111 bool internal() const { return _internal; }
112 SystemProperty* next() const { return _next; }
453
454 static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v,
455 PropertyAppendable append, PropertyWriteable writeable,
456 PropertyInternal internal);
457 static const char* PropertyList_get_value(SystemProperty* plist, const char* key);
458 static const char* PropertyList_get_readable_value(SystemProperty* plist, const char* key);
459 static int PropertyList_count(SystemProperty* pl);
460 static int PropertyList_readable_count(SystemProperty* pl);
461
462 static bool is_internal_module_property(const char* option);
463 static bool is_incompatible_cds_internal_module_property(const char* property);
464
465 // Miscellaneous System property value getter and setters.
466 static void set_dll_dir(const char *value) { _sun_boot_library_path->set_value(value); }
467 static void set_java_home(const char *value) { _java_home->set_value(value); }
468 static void set_library_path(const char *value) { _java_library_path->set_value(value); }
469 static void set_ext_dirs(char *value);
470
471 // Set up the underlying pieces of the boot class path
472 static void add_patch_mod_prefix(const char *module_name, const char *path);
473 static void set_boot_class_path(const char *value, bool has_jimage) {
474 // During start up, set by os::set_boot_path()
475 assert(get_boot_class_path() == nullptr, "Boot class path previously set");
476 _boot_class_path->set_value(value);
477 _has_jimage = has_jimage;
478 }
479 static void append_sysclasspath(const char *value) {
480 _boot_class_path->append_value(value);
481 _jdk_boot_class_path_append->append_value(value);
482 }
483
484 static GrowableArray<ModulePatchPath*>* get_patch_mod_prefix() { return _patch_mod_prefix; }
485 static char* get_boot_class_path() { return _boot_class_path->value(); }
486 static bool has_jimage() { return _has_jimage; }
487
488 static char* get_java_home() { return _java_home->value(); }
489 static char* get_dll_dir() { return _sun_boot_library_path->value(); }
490 static char* get_appclasspath() { return _java_class_path->value(); }
491 static void fix_appclasspath();
492
493 // Operation modi
494 static Mode mode() { return _mode; }
495 static void set_mode_flags(Mode mode);
496 static bool is_interpreter_only() { return mode() == _int; }
497 static bool is_compiler_only() { return mode() == _comp; }
498
499
500 // preview features
501 static void set_enable_preview() { _enable_preview = true; }
502 static bool enable_preview() { return _enable_preview; }
503
504 // jdwp
505 static bool has_jdwp_agent() { return _has_jdwp_agent; }
506
507 // Utility: copies src into buf, replacing "%%" with "%" and "%p" with pid.
508 static bool copy_expand_pid(const char* src, size_t srclen, char* buf, size_t buflen);
509
510 static bool atojulong(const char *s, julong* result);
511
512 static bool has_jfr_option() NOT_JFR_RETURN_(false);
513
514 DEBUG_ONLY(static bool verify_special_jvm_flags(bool check_globals);)
515 };
516
517 // Disable options not supported in this release, with a warning if they
518 // were explicitly requested on the command-line
519 #define UNSUPPORTED_OPTION(opt) \
520 do { \
521 if (opt) { \
522 if (FLAG_IS_CMDLINE(opt)) { \
|
1 /*
2 * Copyright (c) 1997, 2026, 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 *
73 void append_value(const char *value);
74
75 PathString(const char* value);
76 ~PathString();
77
78 // for JVM_ReadSystemPropertiesInfo
79 static int value_offset_in_bytes() { return (int)offset_of(PathString, _value); }
80 };
81
82 // ModulePatchPath records the module/path pair as specified to --patch-module.
83 class ModulePatchPath : public CHeapObj<mtInternal> {
84 private:
85 char* _module_name;
86 PathString* _path;
87 public:
88 ModulePatchPath(const char* module_name, const char* path);
89 ~ModulePatchPath();
90
91 inline const char* module_name() const { return _module_name; }
92 inline char* path_string() const { return _path->value(); }
93 inline void append_path(const char* path) { _path->append_value(path); }
94 };
95
96 // Element describing System and User (-Dkey=value flags) defined property.
97 //
98 // An internal SystemProperty is one that has been removed in
99 // jdk.internal.VM.saveAndRemoveProperties, like jdk.boot.class.path.append.
100 //
101 class SystemProperty : public PathString {
102 private:
103 char* _key;
104 SystemProperty* _next;
105 bool _internal;
106 bool _writeable;
107
108 public:
109 // Accessors
110 char* value() const { return PathString::value(); }
111 const char* key() const { return _key; }
112 bool internal() const { return _internal; }
113 SystemProperty* next() const { return _next; }
454
455 static void PropertyList_unique_add(SystemProperty** plist, const char* k, const char* v,
456 PropertyAppendable append, PropertyWriteable writeable,
457 PropertyInternal internal);
458 static const char* PropertyList_get_value(SystemProperty* plist, const char* key);
459 static const char* PropertyList_get_readable_value(SystemProperty* plist, const char* key);
460 static int PropertyList_count(SystemProperty* pl);
461 static int PropertyList_readable_count(SystemProperty* pl);
462
463 static bool is_internal_module_property(const char* option);
464 static bool is_incompatible_cds_internal_module_property(const char* property);
465
466 // Miscellaneous System property value getter and setters.
467 static void set_dll_dir(const char *value) { _sun_boot_library_path->set_value(value); }
468 static void set_java_home(const char *value) { _java_home->set_value(value); }
469 static void set_library_path(const char *value) { _java_library_path->set_value(value); }
470 static void set_ext_dirs(char *value);
471
472 // Set up the underlying pieces of the boot class path
473 static void add_patch_mod_prefix(const char *module_name, const char *path);
474 static int finalize_patch_module();
475
476 static void set_boot_class_path(const char *value, bool has_jimage) {
477 // During start up, set by os::set_boot_path()
478 assert(get_boot_class_path() == nullptr, "Boot class path previously set");
479 _boot_class_path->set_value(value);
480 _has_jimage = has_jimage;
481 }
482 static void append_sysclasspath(const char *value) {
483 _boot_class_path->append_value(value);
484 _jdk_boot_class_path_append->append_value(value);
485 }
486
487 static GrowableArray<ModulePatchPath*>* get_patch_mod_prefix() { return _patch_mod_prefix; }
488 static char* get_boot_class_path() { return _boot_class_path->value(); }
489 static bool has_jimage() { return _has_jimage; }
490
491 static char* get_java_home() { return _java_home->value(); }
492 static char* get_dll_dir() { return _sun_boot_library_path->value(); }
493 static char* get_appclasspath() { return _java_class_path->value(); }
494 static void fix_appclasspath();
495
496 // Operation modi
497 static Mode mode() { return _mode; }
498 static void set_mode_flags(Mode mode);
499 static bool is_interpreter_only() { return mode() == _int; }
500 static bool is_compiler_only() { return mode() == _comp; }
501
502
503 // preview features
504 static void set_enable_preview() { _enable_preview = true; }
505 static bool enable_preview() { return _enable_preview; }
506 static bool is_valhalla_enabled() {
507 // Valhalla is a feature opted-in by --enable-preview
508 return enable_preview();
509 }
510
511 // jdwp
512 static bool has_jdwp_agent() { return _has_jdwp_agent; }
513
514 // Utility: copies src into buf, replacing "%%" with "%" and "%p" with pid.
515 static bool copy_expand_pid(const char* src, size_t srclen, char* buf, size_t buflen);
516
517 static bool atojulong(const char *s, julong* result);
518
519 static bool has_jfr_option() NOT_JFR_RETURN_(false);
520
521 DEBUG_ONLY(static bool verify_special_jvm_flags(bool check_globals);)
522 };
523
524 // Disable options not supported in this release, with a warning if they
525 // were explicitly requested on the command-line
526 #define UNSUPPORTED_OPTION(opt) \
527 do { \
528 if (opt) { \
529 if (FLAG_IS_CMDLINE(opt)) { \
|