Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/classFileParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5176,7 +5176,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik,
assert(module_entry != nullptr, "module_entry should always be set");

// Obtain java.lang.Module
Handle module_handle(THREAD, module_entry->module());
Handle module_handle(THREAD, module_entry->module_oop());

// Allocate mirror and initialize static fields
java_lang_Class::create_mirror(ik,
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/classLoaderDataShared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void ClassLoaderDataShared::clear_archived_oops() {
oop ClassLoaderDataShared::restore_archived_oops_for_null_class_loader_data() {
assert(CDSConfig::is_using_full_module_graph(), "must be");
_archived_boot_loader_data.restore(null_class_loader_data(), false, true);
return _archived_javabase_moduleEntry->module();
return _archived_javabase_moduleEntry->module_oop();
}

void ClassLoaderDataShared::restore_java_platform_loader_from_archive(ClassLoaderData* loader_data) {
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/classfile/javaClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,15 +1036,15 @@ void java_lang_Class::set_mirror_module_field(JavaThread* current, Klass* k, Han
// If java.base was already defined then patch this particular class with java.base.
if (javabase_was_defined) {
ModuleEntry *javabase_entry = ModuleEntryTable::javabase_moduleEntry();
assert(javabase_entry != nullptr && javabase_entry->module() != nullptr,
assert(javabase_entry != nullptr && javabase_entry->module_oop() != nullptr,
"Setting class module field, " JAVA_BASE_NAME " should be defined");
Handle javabase_handle(current, javabase_entry->module());
Handle javabase_handle(current, javabase_entry->module_oop());
set_module(mirror(), javabase_handle());
}
} else {
assert(Universe::is_module_initialized() ||
(ModuleEntryTable::javabase_defined() &&
(module() == ModuleEntryTable::javabase_moduleEntry()->module())),
(module() == ModuleEntryTable::javabase_moduleEntry()->module_oop())),
"Incorrect java.lang.Module specification while creating mirror");
set_module(mirror(), module());
}
Expand Down
16 changes: 8 additions & 8 deletions src/hotspot/share/classfile/moduleEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

ModuleEntry* ModuleEntryTable::_javabase_module = nullptr;

oop ModuleEntry::module() const { return _module.resolve(); }
oop ModuleEntry::module_oop() const { return _module_handle.resolve(); }
Copy link
Member

Choose a reason for hiding this comment

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

(Pre-existing) Just wondering why this one-liner function doesn't reside in the moduleEntry.hpp?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's because OopHandle::resolve() is an inline function, but we are not allowed to include xxx.inline.hpp in non-inlined .hpp files.


void ModuleEntry::set_location(Symbol* location) {
// _location symbol's refcounts are managed by ModuleEntry,
Expand Down Expand Up @@ -284,7 +284,7 @@ ModuleEntry::ModuleEntry(Handle module_handle,
}

if (!module_handle.is_null()) {
_module = loader_data->add_handle(module_handle);
_module_handle = loader_data->add_handle(module_handle);
}

set_version(version);
Expand Down Expand Up @@ -401,7 +401,7 @@ ModuleEntry* ModuleEntry::allocate_archived_entry() const {
memcpy((void*)archived_entry, (void*)this, sizeof(ModuleEntry));

if (CDSConfig::is_dumping_full_module_graph()) {
archived_entry->_archived_module_index = HeapShared::append_root(module());
archived_entry->_archived_module_index = HeapShared::append_root(module_oop());
} else {
archived_entry->_archived_module_index = -1;
}
Expand All @@ -422,7 +422,7 @@ ModuleEntry* ModuleEntry::allocate_archived_entry() const {

// Clear handles and restore at run time. Handles cannot be archived.
OopHandle null_handle;
archived_entry->_module = null_handle;
archived_entry->_module_handle = null_handle;

// For verify_archived_module_entries()
DEBUG_ONLY(_num_inited_module_entries++);
Expand Down Expand Up @@ -526,7 +526,7 @@ void ModuleEntry::restore_archived_oops(ClassLoaderData* loader_data) {
assert(CDSConfig::is_using_archive(), "runtime only");
Handle module_handle(Thread::current(), HeapShared::get_root(_archived_module_index, /*clear=*/true));
assert(module_handle.not_null(), "huh");
set_module(loader_data->add_handle(module_handle));
set_module_handle(loader_data->add_handle(module_handle));

// This was cleared to zero during dump time -- we didn't save the value
// because it may be affected by archive relocation.
Expand Down Expand Up @@ -662,7 +662,7 @@ void ModuleEntryTable::finalize_javabase(Handle module_handle, Symbol* version,
jb_module->set_location(location);
// Once java.base's ModuleEntry _module field is set with the known
// java.lang.Module, java.base is considered "defined" to the VM.
jb_module->set_module(boot_loader_data->add_handle(module_handle));
jb_module->set_module_handle(boot_loader_data->add_handle(module_handle));

// Store pointer to the ModuleEntry for java.base in the java.lang.Module object.
java_lang_Module::set_module_entry(module_handle(), jb_module);
Expand Down Expand Up @@ -700,7 +700,7 @@ void ModuleEntryTable::patch_javabase_entries(JavaThread* current, Handle module
// We allow -XX:ArchiveHeapTestClass to archive additional classes
// into the CDS heap, but these must be in the unnamed module.
ModuleEntry* unnamed_module = ClassLoaderData::the_null_class_loader_data()->unnamed_module();
Handle unnamed_module_handle(current, unnamed_module->module());
Handle unnamed_module_handle(current, unnamed_module->module_oop());
java_lang_Class::fixup_module_field(k, unnamed_module_handle);
} else
#endif
Expand Down Expand Up @@ -745,7 +745,7 @@ void ModuleEntry::print(outputStream* st) {
st->print_cr("entry " PTR_FORMAT " name %s module " PTR_FORMAT " loader %s version %s location %s strict %s",
p2i(this),
name_as_C_string(),
p2i(module()),
p2i(module_oop()),
loader_data()->loader_name_and_id(),
version() != nullptr ? version()->as_C_string() : "nullptr",
location() != nullptr ? location()->as_C_string() : "nullptr",
Expand Down
12 changes: 6 additions & 6 deletions src/hotspot/share/classfile/moduleEntry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ModuleClosure;
// A ModuleEntry describes a module that has been defined by a call to JVM_DefineModule.
// It contains:
// - Symbol* containing the module's name.
// - pointer to the java.lang.Module for this module.
// - pointer to the java.lang.Module: the representation of this module as a Java object
// - pointer to the java.security.ProtectionDomain shared by classes defined to this module.
// - ClassLoaderData*, class loader of this module.
// - a growable array containing other module entries that this module can read.
Expand All @@ -63,7 +63,7 @@ class ModuleClosure;
// data structure. This lock must be taken on all accesses to either table.
class ModuleEntry : public CHeapObj<mtModule> {
private:
OopHandle _module; // java.lang.Module
OopHandle _module_handle; // java.lang.Module
OopHandle _shared_pd; // java.security.ProtectionDomain, cached
// for shared classes from this module
Symbol* _name; // name of this module
Expand Down Expand Up @@ -96,9 +96,9 @@ class ModuleEntry : public CHeapObj<mtModule> {
~ModuleEntry();

Symbol* name() const { return _name; }
oop module() const;
OopHandle module_handle() const { return _module; }
void set_module(OopHandle j) { _module = j; }
oop module_oop() const;
OopHandle module_handle() const { return _module_handle; }
void set_module_handle(OopHandle j) { _module_handle = j; }

// The shared ProtectionDomain reference is set once the VM loads a shared class
// originated from the current Module. The referenced ProtectionDomain object is
Expand Down Expand Up @@ -262,7 +262,7 @@ class ModuleEntryTable : public CHeapObj<mtModule> {
}

static bool javabase_defined() { return ((_javabase_module != nullptr) &&
(_javabase_module->module() != nullptr)); }
(_javabase_module->module_oop() != nullptr)); }
static void finalize_javabase(Handle module_handle, Symbol* version, Symbol* location);
static void patch_javabase_entries(JavaThread* current, Handle module_handle);

Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/classfile/modules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ void Modules::set_bootloader_unnamed_module(Handle module, TRAPS) {
ClassLoaderData* boot_loader_data = ClassLoaderData::the_null_class_loader_data();
ModuleEntry* unnamed_module = boot_loader_data->unnamed_module();
assert(unnamed_module != nullptr, "boot loader's unnamed ModuleEntry not defined");
unnamed_module->set_module(boot_loader_data->add_handle(module));
unnamed_module->set_module_handle(boot_loader_data->add_handle(module));
// Store pointer to the ModuleEntry in the unnamed module's java.lang.Module object.
java_lang_Module::set_module_entry(module(), unnamed_module);
}
Expand Down Expand Up @@ -954,8 +954,8 @@ oop Modules::get_named_module(Handle h_loader, const char* package_name) {
get_package_entry_by_name(package_sym, h_loader);
const ModuleEntry* const module_entry = (pkg_entry != nullptr ? pkg_entry->module() : nullptr);

if (module_entry != nullptr && module_entry->module() != nullptr && module_entry->is_named()) {
return module_entry->module();
if (module_entry != nullptr && module_entry->module_oop() != nullptr && module_entry->is_named()) {
return module_entry->module_oop();
}
return nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/jfr/jni/jfrUpcalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ ClassFileStream* JfrUpcalls::on_method_trace(InstanceKlass* ik, const ClassFileS
ModuleEntry* module_entry = ik->module();
oop module = nullptr;
if (module_entry != nullptr) {
module = module_entry->module();
module = module_entry->module_oop();
}
instanceHandle module_handle(THREAD, (instanceOop)module);

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/jvmci/jvmciCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ bool JVMCICompiler::force_comp_at_level_simple(const methodHandle& method) {
if (excludeModules.not_null()) {
ModuleEntry* moduleEntry = method->method_holder()->module();
for (int i = 0; i < excludeModules->length(); i++) {
if (excludeModules->obj_at(i) == moduleEntry->module()) {
if (excludeModules->obj_at(i) == moduleEntry->module_oop()) {
return true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/oops/arrayKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ void ArrayKlass::complete_create_array_klass(ArrayKlass* k, Klass* super_klass,
// java.base is defined.
assert((module_entry != nullptr) || ((module_entry == nullptr) && !ModuleEntryTable::javabase_defined()),
"module entry not available post " JAVA_BASE_NAME " definition");
oop module = (module_entry != nullptr) ? module_entry->module() : (oop)nullptr;
java_lang_Class::create_mirror(k, Handle(THREAD, k->class_loader()), Handle(THREAD, module), Handle(), Handle(), CHECK);
oop module_oop = (module_entry != nullptr) ? module_entry->module_oop() : (oop)nullptr;
java_lang_Class::create_mirror(k, Handle(THREAD, k->class_loader()), Handle(THREAD, module_oop), Handle(), Handle(), CHECK);
}

ArrayKlass* ArrayKlass::array_klass(int n, TRAPS) {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/oops/klass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protec
module_entry = ModuleEntryTable::javabase_moduleEntry();
}
// Obtain java.lang.Module, if available
Handle module_handle(THREAD, ((module_entry != nullptr) ? module_entry->module() : (oop)nullptr));
Handle module_handle(THREAD, ((module_entry != nullptr) ? module_entry->module_oop() : (oop)nullptr));

if (this->has_archived_mirror_index()) {
ResourceMark rm(THREAD);
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/prims/jvmtiExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,12 +943,12 @@ class JvmtiClassFileLoadHookPoster : public StackObj {
ModuleEntry* module_entry = InstanceKlass::cast(klass)->module();
assert(module_entry != nullptr, "module_entry should always be set");
if (module_entry->is_named() &&
module_entry->module() != nullptr &&
module_entry->module_oop() != nullptr &&
!module_entry->has_default_read_edges()) {
if (!module_entry->set_has_default_read_edges()) {
// We won a potential race.
// Add read edges to the unnamed modules of the bootstrap and app class loaders
Handle class_module(_thread, module_entry->module()); // Obtain j.l.r.Module
Handle class_module(_thread, module_entry->module_oop()); // Obtain j.l.r.Module
JvmtiExport::add_default_read_edges(class_module, _thread);
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/hotspot/share/runtime/reflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,9 @@ char* Reflection::verify_class_access_msg(const Klass* current_class,
current_class_name, module_from_name, new_class_name,
module_to_name, module_from_name, module_to_name);
} else {
oop jlm = module_to->module();
assert(jlm != nullptr, "Null jlm in module_to ModuleEntry");
intptr_t identity_hash = jlm->identity_hash();
oop module_oop = module_to->module_oop();
assert(module_oop != nullptr, "should have been initialized");
intptr_t identity_hash = module_oop->identity_hash();
size_t len = 160 + strlen(current_class_name) + 2*strlen(module_from_name) +
strlen(new_class_name) + 2*sizeof(uintx);
msg = NEW_RESOURCE_ARRAY(char, len);
Expand All @@ -578,9 +578,9 @@ char* Reflection::verify_class_access_msg(const Klass* current_class,
current_class_name, module_from_name, new_class_name,
module_to_name, module_to_name, package_name, module_from_name);
} else {
oop jlm = module_from->module();
assert(jlm != nullptr, "Null jlm in module_from ModuleEntry");
intptr_t identity_hash = jlm->identity_hash();
oop module_oop = module_from->module_oop();
assert(module_oop != nullptr, "should have been initialized");
intptr_t identity_hash = module_oop->identity_hash();
size_t len = 170 + strlen(current_class_name) + strlen(new_class_name) +
2*strlen(module_to_name) + strlen(package_name) + 2*sizeof(uintx);
msg = NEW_RESOURCE_ARRAY(char, len);
Expand Down