ModuleEntry::_reads is declared as an GrowableArray<ModuleEntry*>*, but when stored in a CDS archive, we assign an Array<ModuleEntry*>* to this field with a type cast:
https://github.com/openjdk/jdk/commit/03a4df0acd103702e52dcd01c3f03fda4d7b04f5#diff-3ddec12a402a8e4f3993dc642c7f8cb7ca277553deff15ae00b10392f6322ffcR450
_reads = (GrowableArray<ModuleEntry*>*)archived_reads;
There's a corresponding cast that converts the Array<ModuleEntry*>* back to a GrowableArray<ModuleEntry*>*:
void ModuleEntry::load_from_archive(ClassLoaderData* loader_data) {
assert(CDSConfig::is_loading_full_module_graph(), "runtime only");
set_loader_data(loader_data);
_reads = restore_growable_array((Array<ModuleEntry*>*)_reads);
JFR_ONLY(INIT_ID(this);)
}
This code is confusing and should be fixed (use a union type??)
https://github.com/openjdk/jdk/commit/03a4df0acd103702e52dcd01c3f03fda4d7b04f5#diff-3ddec12a402a8e4f3993dc642c7f8cb7ca277553deff15ae00b10392f6322ffcR450
_reads = (GrowableArray<ModuleEntry*>*)archived_reads;
There's a corresponding cast that converts the Array<ModuleEntry*>* back to a GrowableArray<ModuleEntry*>*:
void ModuleEntry::load_from_archive(ClassLoaderData* loader_data) {
assert(CDSConfig::is_loading_full_module_graph(), "runtime only");
set_loader_data(loader_data);
_reads = restore_growable_array((Array<ModuleEntry*>*)_reads);
JFR_ONLY(INIT_ID(this);)
}
This code is confusing and should be fixed (use a union type??)