< prev index next >

src/hotspot/share/classfile/systemDictionary.cpp

Print this page


1340           pkg_entry->in_unnamed_module()) {
1341         assert(mod_entry == NULL ||
1342                mod_entry == loader_data->unnamed_module(),
1343                "the unnamed module is not defined in the classloader");
1344         return true;
1345       }
1346     }
1347     return false;
1348   } else {
1349     bool res = SystemDictionaryShared::is_shared_class_visible_for_classloader(
1350               ik, class_loader, pkg_name, pkg_entry, mod_entry, CHECK_(false));
1351     return res;
1352   }
1353 }
1354 
1355 bool SystemDictionary::is_shared_class_visible_impl(Symbol* class_name,
1356                                                InstanceKlass* ik,
1357                                                PackageEntry* pkg_entry,
1358                                                Handle class_loader, TRAPS) {
1359   int scp_index = ik->shared_classpath_index();

1360   assert(scp_index >= 0, "must be");
1361   SharedClassPathEntry* scp_entry = FileMapInfo::shared_path(scp_index);
1362   if (!Universe::is_module_initialized()) {
1363     assert(scp_entry != NULL && scp_entry->is_modules_image(),
1364            "Loading non-bootstrap classes before the module system is initialized");
1365     assert(class_loader.is_null(), "sanity");
1366     return true;
1367   }
1368 
1369   ModuleEntry* mod_entry = (pkg_entry == NULL) ? NULL : pkg_entry->module();
1370   bool should_be_in_named_module = (mod_entry != NULL && mod_entry->is_named());
1371   bool was_archived_from_named_module = scp_entry->in_named_module();
1372   bool visible;
1373 
1374   if (was_archived_from_named_module) {
1375     if (should_be_in_named_module) {
1376       // Is the module loaded from the same location as during dump time?
1377       visible = mod_entry->shared_path_index() == scp_index;



1378     } else {
1379       // During dump time, this class was in a named module, but at run time, this class should be
1380       // in an unnamed module.
1381       visible = false;
1382     }
1383   } else {
1384     if (should_be_in_named_module) {
1385       // During dump time, this class was in an unnamed, but at run time, this class should be
1386       // in a named module.
1387       visible = false;
1388     } else {
1389       visible = true;
1390     }
1391   }
1392 
1393   DEBUG_ONLY(bool visible_old = is_shared_class_visible_impl_old(class_name,
1394                                                                  ik,
1395                                                                  pkg_entry,
1396                                                                  class_loader,
1397                                                                  scp_entry,




1340           pkg_entry->in_unnamed_module()) {
1341         assert(mod_entry == NULL ||
1342                mod_entry == loader_data->unnamed_module(),
1343                "the unnamed module is not defined in the classloader");
1344         return true;
1345       }
1346     }
1347     return false;
1348   } else {
1349     bool res = SystemDictionaryShared::is_shared_class_visible_for_classloader(
1350               ik, class_loader, pkg_name, pkg_entry, mod_entry, CHECK_(false));
1351     return res;
1352   }
1353 }
1354 
1355 bool SystemDictionary::is_shared_class_visible_impl(Symbol* class_name,
1356                                                     InstanceKlass* ik,
1357                                                     PackageEntry* pkg_entry,
1358                                                     Handle class_loader, TRAPS) {
1359   int scp_index = ik->shared_classpath_index();
1360   assert(!ik->is_shared_unregistered_class(), "this function should be called for built-in classes only");
1361   assert(scp_index >= 0, "must be");
1362   SharedClassPathEntry* scp_entry = FileMapInfo::shared_path(scp_index);
1363   if (!Universe::is_module_initialized()) {
1364     assert(scp_entry != NULL && scp_entry->is_modules_image(),
1365            "Loading non-bootstrap classes before the module system is initialized");
1366     assert(class_loader.is_null(), "sanity");
1367     return true;
1368   }
1369 
1370   ModuleEntry* mod_entry = (pkg_entry == NULL) ? NULL : pkg_entry->module();
1371   bool should_be_in_named_module = (mod_entry != NULL && mod_entry->is_named());
1372   bool was_archived_from_named_module = scp_entry->in_named_module();
1373   bool visible;
1374 
1375   if (was_archived_from_named_module) {
1376     if (should_be_in_named_module) {
1377       // Is the module loaded from the same location as during dump time?
1378       visible = mod_entry->shared_path_index() == scp_index;
1379       if (visible) {
1380         assert(!mod_entry->is_patched(), "cannot load archived classes for patched module");
1381       }
1382     } else {
1383       // During dump time, this class was in a named module, but at run time, this class should be
1384       // in an unnamed module.
1385       visible = false;
1386     }
1387   } else {
1388     if (should_be_in_named_module) {
1389       // During dump time, this class was in an unnamed, but at run time, this class should be
1390       // in a named module.
1391       visible = false;
1392     } else {
1393       visible = true;
1394     }
1395   }
1396 
1397   DEBUG_ONLY(bool visible_old = is_shared_class_visible_impl_old(class_name,
1398                                                                  ik,
1399                                                                  pkg_entry,
1400                                                                  class_loader,
1401                                                                  scp_entry,


< prev index next >