< prev index next > src/hotspot/share/classfile/modules.cpp
Print this page
}
}
void Modules::define_module(Handle module, jboolean is_open, jstring version,
jstring location, jobjectArray packages, TRAPS) {
- check_cds_restrictions(CHECK);
ResourceMark rm(THREAD);
if (module.is_null()) {
THROW_MSG(vmSymbols::java_lang_NullPointerException(), "Null module object");
}
}
// Resolve packages
objArrayHandle packages_h(THREAD, objArrayOop(JNIHandles::resolve(packages)));
int num_packages = (packages_h.is_null() ? 0 : packages_h->length());
+ if (strncmp(module_name, "jdk.proxy", 9) != 0) {
+ check_cds_restrictions(Handle(), Handle(), CHECK);
+ }
// Special handling of java.base definition
if (strcmp(module_name, JAVA_BASE_NAME) == 0) {
assert(is_open == JNI_FALSE, "java.base module cannot be open");
define_javabase_module(module, version, location, packages_h, num_packages, CHECK);
assert(Arguments::get_property("java.system.class.loader") == nullptr,
"archived full module should have been disabled if -Djava.system.class.loader is specified");
ClassLoaderDataShared::restore_java_system_loader_from_archive(system_loader_data);
}
! void Modules::check_cds_restrictions(TRAPS) {
if (CDSConfig::is_dumping_full_module_graph() && Universe::is_module_initialized()) {
! THROW_MSG(vmSymbols::java_lang_UnsupportedOperationException(),
! "During -Xshare:dump, module system cannot be modified after it's initialized");
}
}
#endif // INCLUDE_CDS_JAVA_HEAP
void Modules::set_bootloader_unnamed_module(Handle module, TRAPS) {
ResourceMark rm(THREAD);
if (module.is_null()) {
THROW_MSG(vmSymbols::java_lang_NullPointerException(), "Null module object");
assert(Arguments::get_property("java.system.class.loader") == nullptr,
"archived full module should have been disabled if -Djava.system.class.loader is specified");
ClassLoaderDataShared::restore_java_system_loader_from_archive(system_loader_data);
}
! void Modules::check_cds_restrictions(Handle module1, Handle module2, TRAPS) {
if (CDSConfig::is_dumping_full_module_graph() && Universe::is_module_initialized()) {
! if (CDSConfig::is_dumping_dynamic_proxies() && (is_dynamic_proxy_module(module1) || is_dynamic_proxy_module(module2))) {
! // The only the we allow is to add or modify the jdk.proxy?? modules that are used for dynamic proxies.
+ } else {
+ THROW_MSG(vmSymbols::java_lang_UnsupportedOperationException(),
+ "During -Xshare:dump, module system cannot be modified after it's initialized");
+ }
}
}
+
#endif // INCLUDE_CDS_JAVA_HEAP
+ bool Modules::is_dynamic_proxy_module(Handle module) {
+ if (!module.is_null()) {
+ ModuleEntry* module_entry = java_lang_Module::module_entry(module());
+ return is_dynamic_proxy_module(module_entry);
+ }
+ return false;
+ }
+
+ bool Modules::is_dynamic_proxy_module(ModuleEntry* module_entry) {
+ return (module_entry != nullptr && module_entry->is_named() && module_entry->name()->starts_with("jdk.proxy"));
+ }
+
void Modules::set_bootloader_unnamed_module(Handle module, TRAPS) {
ResourceMark rm(THREAD);
if (module.is_null()) {
THROW_MSG(vmSymbols::java_lang_NullPointerException(), "Null module object");
// Store pointer to the ModuleEntry in the unnamed module's java.lang.Module object.
java_lang_Module::set_module_entry(module(), unnamed_module);
}
void Modules::add_module_exports(Handle from_module, jstring package_name, Handle to_module, TRAPS) {
! check_cds_restrictions(CHECK);
if (package_name == nullptr) {
THROW_MSG(vmSymbols::java_lang_NullPointerException(),
"package is null");
}
// Store pointer to the ModuleEntry in the unnamed module's java.lang.Module object.
java_lang_Module::set_module_entry(module(), unnamed_module);
}
void Modules::add_module_exports(Handle from_module, jstring package_name, Handle to_module, TRAPS) {
! check_cds_restrictions(from_module, to_module, CHECK);
if (package_name == nullptr) {
THROW_MSG(vmSymbols::java_lang_NullPointerException(),
"package is null");
}
}
void Modules::add_module_exports_qualified(Handle from_module, jstring package,
Handle to_module, TRAPS) {
! check_cds_restrictions(CHECK);
if (to_module.is_null()) {
THROW_MSG(vmSymbols::java_lang_NullPointerException(),
"to_module is null");
}
add_module_exports(from_module, package, to_module, CHECK);
}
void Modules::add_reads_module(Handle from_module, Handle to_module, TRAPS) {
! check_cds_restrictions(CHECK);
if (from_module.is_null()) {
THROW_MSG(vmSymbols::java_lang_NullPointerException(),
"from_module is null");
}
}
void Modules::add_module_exports_qualified(Handle from_module, jstring package,
Handle to_module, TRAPS) {
! check_cds_restrictions(from_module, to_module, CHECK);
if (to_module.is_null()) {
THROW_MSG(vmSymbols::java_lang_NullPointerException(),
"to_module is null");
}
add_module_exports(from_module, package, to_module, CHECK);
}
void Modules::add_reads_module(Handle from_module, Handle to_module, TRAPS) {
! check_cds_restrictions(from_module, to_module, CHECK);
if (from_module.is_null()) {
THROW_MSG(vmSymbols::java_lang_NullPointerException(),
"from_module is null");
}
return nullptr;
}
// Export package in module to all unnamed modules.
void Modules::add_module_exports_to_all_unnamed(Handle module, jstring package_name, TRAPS) {
! check_cds_restrictions(CHECK);
if (module.is_null()) {
THROW_MSG(vmSymbols::java_lang_NullPointerException(),
"module is null");
}
if (package_name == nullptr) {
return nullptr;
}
// Export package in module to all unnamed modules.
void Modules::add_module_exports_to_all_unnamed(Handle module, jstring package_name, TRAPS) {
! check_cds_restrictions(Handle(), module, CHECK);
if (module.is_null()) {
THROW_MSG(vmSymbols::java_lang_NullPointerException(),
"module is null");
}
if (package_name == nullptr) {
< prev index next >