8247449: Revisit the argument processing logic for MetaspaceShared::disable_optimized_module_handling()

Reviewed-by: iklam, matsaave
This commit is contained in:
Calvin Cheung 2024-03-28 15:03:09 +00:00
parent aa595dbda4
commit 85cb4a9942
3 changed files with 25 additions and 9 deletions
src/hotspot/share

@ -235,18 +235,29 @@ void CDSConfig::init_shared_archive_paths() {
}
}
void CDSConfig::check_system_property(const char* key, const char* value) {
void CDSConfig::check_internal_module_property(const char* key, const char* value) {
if (Arguments::is_internal_module_property(key)) {
stop_using_optimized_module_handling();
log_info(cds)("optimized module handling: disabled due to incompatible property: %s=%s", key, value);
}
if (strcmp(key, "jdk.module.showModuleResolution") == 0 ||
strcmp(key, "jdk.module.validation") == 0 ||
strcmp(key, "java.system.class.loader") == 0) {
stop_dumping_full_module_graph();
stop_using_full_module_graph();
log_info(cds)("full module graph: disabled due to incompatible property: %s=%s", key, value);
}
void CDSConfig::check_incompatible_property(const char* key, const char* value) {
static const char* incompatible_properties[] = {
"java.system.class.loader",
"jdk.module.showModuleResolution",
"jdk.module.validation"
};
for (const char* property : incompatible_properties) {
if (strcmp(key, property) == 0) {
stop_dumping_full_module_graph();
stop_using_full_module_graph();
log_info(cds)("full module graph: disabled due to incompatible property: %s=%s", key, value);
break;
}
}
}
static const char* unsupported_properties[] = {

@ -58,7 +58,8 @@ public:
// Initialization and command-line checking
static void initialize() NOT_CDS_RETURN;
static void check_system_property(const char* key, const char* value) NOT_CDS_RETURN;
static void check_internal_module_property(const char* key, const char* value) NOT_CDS_RETURN;
static void check_incompatible_property(const char* key, const char* value) NOT_CDS_RETURN;
static void check_unsupported_dumping_properties() NOT_CDS_RETURN;
static bool check_vm_args_consistency(bool patch_mod_javabase, bool mode_flag_cmd_line) NOT_CDS_RETURN_(true);

@ -1261,7 +1261,9 @@ bool Arguments::add_property(const char* prop, PropertyWriteable writeable, Prop
value = &prop[key_len + 1];
}
CDSConfig::check_system_property(key, value);
if (internal == ExternalProperty) {
CDSConfig::check_incompatible_property(key, value);
}
if (strcmp(key, "java.compiler") == 0) {
// we no longer support java.compiler system property, log a warning and let it get
@ -1900,6 +1902,7 @@ bool Arguments::parse_uint(const char* value,
bool Arguments::create_module_property(const char* prop_name, const char* prop_value, PropertyInternal internal) {
assert(is_internal_module_property(prop_name), "unknown module property: '%s'", prop_name);
CDSConfig::check_internal_module_property(prop_name, prop_value);
size_t prop_len = strlen(prop_name) + strlen(prop_value) + 2;
char* property = AllocateHeap(prop_len, mtArguments);
int ret = jio_snprintf(property, prop_len, "%s=%s", prop_name, prop_value);
@ -1919,6 +1922,7 @@ bool Arguments::create_module_property(const char* prop_name, const char* prop_v
bool Arguments::create_numbered_module_property(const char* prop_base_name, const char* prop_value, unsigned int count) {
assert(is_internal_module_property(prop_base_name), "unknown module property: '%s'", prop_base_name);
CDSConfig::check_internal_module_property(prop_base_name, prop_value);
const unsigned int props_count_limit = 1000;
const int max_digits = 3;
const int extra_symbols_count = 3; // includes '.', '=', '\0'