< prev index next >

src/hotspot/share/classfile/systemDictionary.cpp

Print this page
rev 58452 : imported patch pkg_name_from_class


1180   int path_index = ik->shared_classpath_index();
1181   ClassLoaderData* loader_data = class_loader_data(class_loader);
1182   if (path_index < 0) {
1183     // path_index < 0 indicates that the class is intended for a custom loader
1184     // and should not be loaded by boot/platform/app loaders
1185     if (loader_data->is_builtin_class_loader_data()) {
1186       return false;
1187     } else {
1188       return true;
1189     }
1190   }
1191   SharedClassPathEntry* ent =
1192             (SharedClassPathEntry*)FileMapInfo::shared_path(path_index);
1193   if (!Universe::is_module_initialized()) {
1194     assert(ent != NULL && ent->is_modules_image(),
1195            "Loading non-bootstrap classes before the module system is initialized");
1196     assert(class_loader.is_null(), "sanity");
1197     return true;
1198   }
1199   // Get the pkg_entry from the classloader
1200   TempNewSymbol pkg_name = NULL;
1201   PackageEntry* pkg_entry = NULL;
1202   ModuleEntry* mod_entry = NULL;
1203   pkg_name = InstanceKlass::package_from_name(class_name, CHECK_false);
1204   if (pkg_name != NULL) {
1205     if (loader_data != NULL) {
1206       pkg_entry = loader_data->packages()->lookup_only(pkg_name);
1207     }
1208     if (pkg_entry != NULL) {
1209       mod_entry = pkg_entry->module();
1210     }
1211   }
1212 
1213   // If the archived class is from a module that has been patched at runtime,
1214   // the class cannot be loaded from the archive.
1215   if (mod_entry != NULL && mod_entry->is_patched()) {
1216     return false;
1217   }
1218 
1219   if (class_loader.is_null()) {
1220     assert(ent != NULL, "Shared class for NULL classloader must have valid SharedClassPathEntry");
1221     // The NULL classloader can load archived class originated from the
1222     // "modules" jimage and the -Xbootclasspath/a. For class from the
1223     // "modules" jimage, the PackageEntry/ModuleEntry must be defined


1340     HandleMark hm(THREAD);
1341     Handle lockObject = compute_loader_lock_object(class_loader, THREAD);
1342     check_loader_lock_contention(lockObject, THREAD);
1343     ObjectLocker ol(lockObject, THREAD, true);
1344     // prohibited package check assumes all classes loaded from archive call
1345     // restore_unshareable_info which calls ik->set_package()
1346     ik->restore_unshareable_info(loader_data, protection_domain, CHECK_NULL);
1347   }
1348 
1349   load_shared_class_misc(ik, loader_data, CHECK_NULL);
1350   return ik;
1351 }
1352 
1353 void SystemDictionary::load_shared_class_misc(InstanceKlass* ik, ClassLoaderData* loader_data, TRAPS) {
1354   ik->print_class_load_logging(loader_data, NULL, NULL);
1355 
1356   // For boot loader, ensure that GetSystemPackage knows that a class in this
1357   // package was loaded.
1358   if (loader_data->is_the_null_class_loader_data()) {
1359     int path_index = ik->shared_classpath_index();
1360     ResourceMark rm(THREAD);
1361     ClassLoader::add_package(ik->name()->as_C_string(), path_index, THREAD);
1362   }
1363 
1364   if (DumpLoadedClassList != NULL && classlist_file->is_open()) {
1365     // Only dump the classes that can be stored into CDS archive
1366     if (SystemDictionaryShared::is_sharing_possible(loader_data)) {
1367       ResourceMark rm(THREAD);
1368       classlist_file->print_cr("%s", ik->name()->as_C_string());
1369       classlist_file->flush();
1370     }
1371   }
1372 
1373   // notify a class loaded from shared object
1374   ClassLoadingService::notify_class_loaded(ik, true /* shared class */);
1375 
1376   ik->set_has_passed_fingerprint_check(false);
1377   if (UseAOT && ik->supers_have_passed_fingerprint_checks()) {
1378     uint64_t aot_fp = AOTLoader::get_saved_fingerprint(ik);
1379     uint64_t cds_fp = ik->get_stored_fingerprint();
1380     if (aot_fp != 0 && aot_fp == cds_fp) {
1381       // This class matches with a class saved in an AOT library


1413 
1414   klass->restore_unshareable_info(loader_data, domain, THREAD);
1415   load_shared_class_misc(klass, loader_data, CHECK);
1416   Dictionary* dictionary = loader_data->dictionary();
1417   unsigned int hash = dictionary->compute_hash(klass->name());
1418   dictionary->add_klass(hash, klass->name(), klass);
1419   add_to_hierarchy(klass, CHECK);
1420   assert(klass->is_loaded(), "Must be in at least loaded state");
1421 }
1422 #endif // INCLUDE_CDS
1423 
1424 InstanceKlass* SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) {
1425 
1426   if (class_loader.is_null()) {
1427     ResourceMark rm(THREAD);
1428     PackageEntry* pkg_entry = NULL;
1429     bool search_only_bootloader_append = false;
1430     ClassLoaderData *loader_data = class_loader_data(class_loader);
1431 
1432     // Find the package in the boot loader's package entry table.
1433     TempNewSymbol pkg_name = InstanceKlass::package_from_name(class_name, CHECK_NULL);
1434     if (pkg_name != NULL) {
1435       pkg_entry = loader_data->packages()->lookup_only(pkg_name);
1436     }
1437 
1438     // Prior to attempting to load the class, enforce the boot loader's
1439     // visibility boundaries.
1440     if (!Universe::is_module_initialized()) {
1441       // During bootstrapping, prior to module initialization, any
1442       // class attempting to be loaded must be checked against the
1443       // java.base packages in the boot loader's PackageEntryTable.
1444       // No class outside of java.base is allowed to be loaded during
1445       // this bootstrapping window.
1446       if (pkg_entry == NULL || pkg_entry->in_unnamed_module()) {
1447         // Class is either in the unnamed package or in
1448         // a named package within the unnamed module.  Either
1449         // case is outside of java.base, do not attempt to
1450         // load the class post java.base definition.  If
1451         // java.base has not been defined, let the class load
1452         // and its package will be checked later by
1453         // ModuleEntryTable::verify_javabase_packages.




1180   int path_index = ik->shared_classpath_index();
1181   ClassLoaderData* loader_data = class_loader_data(class_loader);
1182   if (path_index < 0) {
1183     // path_index < 0 indicates that the class is intended for a custom loader
1184     // and should not be loaded by boot/platform/app loaders
1185     if (loader_data->is_builtin_class_loader_data()) {
1186       return false;
1187     } else {
1188       return true;
1189     }
1190   }
1191   SharedClassPathEntry* ent =
1192             (SharedClassPathEntry*)FileMapInfo::shared_path(path_index);
1193   if (!Universe::is_module_initialized()) {
1194     assert(ent != NULL && ent->is_modules_image(),
1195            "Loading non-bootstrap classes before the module system is initialized");
1196     assert(class_loader.is_null(), "sanity");
1197     return true;
1198   }
1199   // Get the pkg_entry from the classloader

1200   PackageEntry* pkg_entry = NULL;
1201   ModuleEntry* mod_entry = NULL;
1202   TempNewSymbol pkg_name = InstanceKlass::package_from_name(class_name);
1203   if (pkg_name != NULL) {
1204     if (loader_data != NULL) {
1205       pkg_entry = loader_data->packages()->lookup_only(pkg_name);
1206     }
1207     if (pkg_entry != NULL) {
1208       mod_entry = pkg_entry->module();
1209     }
1210   }
1211 
1212   // If the archived class is from a module that has been patched at runtime,
1213   // the class cannot be loaded from the archive.
1214   if (mod_entry != NULL && mod_entry->is_patched()) {
1215     return false;
1216   }
1217 
1218   if (class_loader.is_null()) {
1219     assert(ent != NULL, "Shared class for NULL classloader must have valid SharedClassPathEntry");
1220     // The NULL classloader can load archived class originated from the
1221     // "modules" jimage and the -Xbootclasspath/a. For class from the
1222     // "modules" jimage, the PackageEntry/ModuleEntry must be defined


1339     HandleMark hm(THREAD);
1340     Handle lockObject = compute_loader_lock_object(class_loader, THREAD);
1341     check_loader_lock_contention(lockObject, THREAD);
1342     ObjectLocker ol(lockObject, THREAD, true);
1343     // prohibited package check assumes all classes loaded from archive call
1344     // restore_unshareable_info which calls ik->set_package()
1345     ik->restore_unshareable_info(loader_data, protection_domain, CHECK_NULL);
1346   }
1347 
1348   load_shared_class_misc(ik, loader_data, CHECK_NULL);
1349   return ik;
1350 }
1351 
1352 void SystemDictionary::load_shared_class_misc(InstanceKlass* ik, ClassLoaderData* loader_data, TRAPS) {
1353   ik->print_class_load_logging(loader_data, NULL, NULL);
1354 
1355   // For boot loader, ensure that GetSystemPackage knows that a class in this
1356   // package was loaded.
1357   if (loader_data->is_the_null_class_loader_data()) {
1358     int path_index = ik->shared_classpath_index();
1359     ClassLoader::add_package(ik, path_index, THREAD);

1360   }
1361 
1362   if (DumpLoadedClassList != NULL && classlist_file->is_open()) {
1363     // Only dump the classes that can be stored into CDS archive
1364     if (SystemDictionaryShared::is_sharing_possible(loader_data)) {
1365       ResourceMark rm(THREAD);
1366       classlist_file->print_cr("%s", ik->name()->as_C_string());
1367       classlist_file->flush();
1368     }
1369   }
1370 
1371   // notify a class loaded from shared object
1372   ClassLoadingService::notify_class_loaded(ik, true /* shared class */);
1373 
1374   ik->set_has_passed_fingerprint_check(false);
1375   if (UseAOT && ik->supers_have_passed_fingerprint_checks()) {
1376     uint64_t aot_fp = AOTLoader::get_saved_fingerprint(ik);
1377     uint64_t cds_fp = ik->get_stored_fingerprint();
1378     if (aot_fp != 0 && aot_fp == cds_fp) {
1379       // This class matches with a class saved in an AOT library


1411 
1412   klass->restore_unshareable_info(loader_data, domain, THREAD);
1413   load_shared_class_misc(klass, loader_data, CHECK);
1414   Dictionary* dictionary = loader_data->dictionary();
1415   unsigned int hash = dictionary->compute_hash(klass->name());
1416   dictionary->add_klass(hash, klass->name(), klass);
1417   add_to_hierarchy(klass, CHECK);
1418   assert(klass->is_loaded(), "Must be in at least loaded state");
1419 }
1420 #endif // INCLUDE_CDS
1421 
1422 InstanceKlass* SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) {
1423 
1424   if (class_loader.is_null()) {
1425     ResourceMark rm(THREAD);
1426     PackageEntry* pkg_entry = NULL;
1427     bool search_only_bootloader_append = false;
1428     ClassLoaderData *loader_data = class_loader_data(class_loader);
1429 
1430     // Find the package in the boot loader's package entry table.
1431     TempNewSymbol pkg_name = InstanceKlass::package_from_name(class_name);
1432     if (pkg_name != NULL) {
1433       pkg_entry = loader_data->packages()->lookup_only(pkg_name);
1434     }
1435 
1436     // Prior to attempting to load the class, enforce the boot loader's
1437     // visibility boundaries.
1438     if (!Universe::is_module_initialized()) {
1439       // During bootstrapping, prior to module initialization, any
1440       // class attempting to be loaded must be checked against the
1441       // java.base packages in the boot loader's PackageEntryTable.
1442       // No class outside of java.base is allowed to be loaded during
1443       // this bootstrapping window.
1444       if (pkg_entry == NULL || pkg_entry->in_unnamed_module()) {
1445         // Class is either in the unnamed package or in
1446         // a named package within the unnamed module.  Either
1447         // case is outside of java.base, do not attempt to
1448         // load the class post java.base definition.  If
1449         // java.base has not been defined, let the class load
1450         // and its package will be checked later by
1451         // ModuleEntryTable::verify_javabase_packages.


< prev index next >