The function bool MetaspaceShared::use_full_module_graph() has two meanings:
- Should we dump the full module graph when doing -Xshare:dump
- Should we load the full module graph when loading a shared archive
This overloaded meaning can lead to strange code:
https://github.com/openjdk/jdk/blob/fe0ccdf5f8a5559a608d2e2cd2b6aecbe245c5ec/src/hotspot/share/oops/instanceKlass.cpp#L2693-L2702
void InstanceKlass::init_shared_package_entry() {
#if !INCLUDE_CDS_JAVA_HEAP
_package_entry = nullptr;
#else
if (!MetaspaceShared::use_full_module_graph()) {
_package_entry = nullptr;
} else if (CDSConfig::is_dumping_dynamic_archive()) {
if (!MetaspaceShared::is_in_shared_metaspace(_package_entry)) {
_package_entry = nullptr;
}
} else {
Here: MetaspaceShared::use_full_module_graph() could mean "we are loading the FMG from the base archive, but we are writing into the dynamic archive, which doesn't have an FMG"
We should split this function to two variants:
CDSConfig::is_dumping_full_module_graph()
CDSConfig::is_loading_full_module_graph()
- Should we dump the full module graph when doing -Xshare:dump
- Should we load the full module graph when loading a shared archive
This overloaded meaning can lead to strange code:
https://github.com/openjdk/jdk/blob/fe0ccdf5f8a5559a608d2e2cd2b6aecbe245c5ec/src/hotspot/share/oops/instanceKlass.cpp#L2693-L2702
void InstanceKlass::init_shared_package_entry() {
#if !INCLUDE_CDS_JAVA_HEAP
_package_entry = nullptr;
#else
if (!MetaspaceShared::use_full_module_graph()) {
_package_entry = nullptr;
} else if (CDSConfig::is_dumping_dynamic_archive()) {
if (!MetaspaceShared::is_in_shared_metaspace(_package_entry)) {
_package_entry = nullptr;
}
} else {
Here: MetaspaceShared::use_full_module_graph() could mean "we are loading the FMG from the base archive, but we are writing into the dynamic archive, which doesn't have an FMG"
We should split this function to two variants:
CDSConfig::is_dumping_full_module_graph()
CDSConfig::is_loading_full_module_graph()