Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/hotspot/share/classfile/modules.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -628,19 +628,22 @@ void Modules::serialize(SerializeClosure* soc) {
}

void Modules::dump_native_access_flag() {
ResourceMark rm;
const char* native_access_names = get_native_access_flags_as_sorted_string();
if (native_access_names != nullptr) {
_archived_native_access_flags = ArchiveBuilder::current()->ro_strdup(native_access_names);
}
}

// Caller needs ResourceMark
const char* Modules::get_native_access_flags_as_sorted_string() {
return get_numbered_property_as_sorted_string("jdk.module.enable.native.access");
}

void Modules::serialize_native_access_flags(SerializeClosure* soc) {
soc->do_ptr(&_archived_native_access_flags);
if (soc->reading()) {
ResourceMark rm;
check_archived_flag_consistency(_archived_native_access_flags, get_native_access_flags_as_sorted_string(), "jdk.module.enable.native.access");

// Don't hold onto the pointer, in case we might decide to unmap the archive.
Expand All @@ -649,28 +652,31 @@ void Modules::serialize_native_access_flags(SerializeClosure* soc) {
}

void Modules::dump_addmods_names() {
ResourceMark rm;
const char* addmods_names = get_addmods_names_as_sorted_string();
if (addmods_names != nullptr) {
_archived_addmods_names = ArchiveBuilder::current()->ro_strdup(addmods_names);
}
}

// Caller needs ResourceMark
const char* Modules::get_addmods_names_as_sorted_string() {
return get_numbered_property_as_sorted_string("jdk.module.addmods");
}

void Modules::serialize_addmods_names(SerializeClosure* soc) {
soc->do_ptr(&_archived_addmods_names);
if (soc->reading()) {
ResourceMark rm;
check_archived_flag_consistency(_archived_addmods_names, get_addmods_names_as_sorted_string(), "jdk.module.addmods");

// Don't hold onto the pointer, in case we might decide to unmap the archive.
_archived_addmods_names = nullptr;
}
}

// Caller needs ResourceMark
const char* Modules::get_numbered_property_as_sorted_string(const char* property) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const char* Modules::get_numbered_property_as_sorted_string(const char* property) {
// Caller needs ResourceMark
const char* Modules::get_numbered_property_as_sorted_string(const char* property) {

ResourceMark rm;
// theoretical string size limit for decimal int, but the following loop will end much sooner due to
// OS command-line size limit.
const int max_digits = 10;
Expand Down Expand Up @@ -723,7 +729,7 @@ const char* Modules::get_numbered_property_as_sorted_string(const char* property
}
}

return (st.size() > 0) ? os::strdup(st.as_string()) : nullptr; // Example: "java.base,java.compiler"
return (st.size() > 0) ? st.as_string() : nullptr; // Example: "java.base,java.compiler"
}

void Modules::define_archived_modules(Handle h_platform_loader, Handle h_system_loader, TRAPS) {
Expand Down