< prev index next >

src/hotspot/share/classfile/systemDictionaryShared.cpp

Print this page




1125 static ResourceHashtable<
1126   Symbol*, bool,
1127   primitive_hash<Symbol*>,
1128   primitive_equals<Symbol*>,
1129   6661,                             // prime number
1130   ResourceObj::C_HEAP> _loaded_unregistered_classes;
1131 
1132 bool SystemDictionaryShared::add_unregistered_class(InstanceKlass* k, TRAPS) {
1133   // We don't allow duplicated unregistered classes of the same name.
1134   assert(DumpSharedSpaces, "only when dumping");
1135   Symbol* name = k->name();
1136   bool created = false;
1137   _loaded_unregistered_classes.put_if_absent(name, true, &created);
1138   if (created) {
1139     MutexLocker mu_r(THREAD, Compile_lock); // add_to_hierarchy asserts this.
1140     SystemDictionary::add_to_hierarchy(k, CHECK_false);
1141   }
1142   return created;
1143 }
1144 









1145 // This function is called to resolve the super/interfaces of shared classes for
1146 // non-built-in loaders. E.g., ChildClass in the below example
1147 // where "super:" (and optionally "interface:") have been specified.
1148 //
1149 // java/lang/Object id: 0
1150 // Interface   id: 2 super: 0 source: cust.jar
1151 // ChildClass  id: 4 super: 0 interfaces: 2 source: cust.jar
1152 InstanceKlass* SystemDictionaryShared::dump_time_resolve_super_or_fail(
1153     Symbol* child_name, Symbol* class_name, Handle class_loader,
1154     Handle protection_domain, bool is_superclass, TRAPS) {
1155 
1156   assert(DumpSharedSpaces, "only when dumping");
1157 
1158   ClassListParser* parser = ClassListParser::instance();
1159   if (parser == NULL) {
1160     // We're still loading the well-known classes, before the ClassListParser is created.
1161     return NULL;
1162   }
1163   if (child_name->equals(parser->current_class_name())) {
1164     // When this function is called, all the numbered super and interface types


1363   } else {
1364     guarantee(k->is_shared_unregistered_class(),
1365               "Class loader type must not be set for UNREGISTERED class %s", name);
1366   }
1367 }
1368 
1369 class ExcludeDumpTimeSharedClasses : StackObj {
1370 public:
1371   bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
1372     if (SystemDictionaryShared::should_be_excluded(k)) {
1373       info.set_excluded();
1374     }
1375     return true; // keep on iterating
1376   }
1377 };
1378 
1379 void SystemDictionaryShared::check_excluded_classes() {
1380   ExcludeDumpTimeSharedClasses excl;
1381   _dumptime_table->iterate(&excl);
1382   _dumptime_table->update_counts();





1383 }
1384 
1385 bool SystemDictionaryShared::is_excluded_class(InstanceKlass* k) {
1386   assert(_no_class_loading_should_happen, "sanity");
1387   Arguments::assert_is_dumping_archive();
1388   return find_or_allocate_info_for(k)->is_excluded();
1389 }
1390 
1391 void SystemDictionaryShared::set_class_has_failed_verification(InstanceKlass* ik) {
1392   Arguments::assert_is_dumping_archive();
1393   find_or_allocate_info_for(ik)->set_failed_verification();
1394 }
1395 
1396 bool SystemDictionaryShared::has_class_failed_verification(InstanceKlass* ik) {
1397   Arguments::assert_is_dumping_archive();
1398   if (_dumptime_table == NULL) {
1399     assert(DynamicDumpSharedSpaces, "sanity");
1400     assert(ik->is_shared(), "must be a shared class in the static archive");
1401     return false;
1402   }




1125 static ResourceHashtable<
1126   Symbol*, bool,
1127   primitive_hash<Symbol*>,
1128   primitive_equals<Symbol*>,
1129   6661,                             // prime number
1130   ResourceObj::C_HEAP> _loaded_unregistered_classes;
1131 
1132 bool SystemDictionaryShared::add_unregistered_class(InstanceKlass* k, TRAPS) {
1133   // We don't allow duplicated unregistered classes of the same name.
1134   assert(DumpSharedSpaces, "only when dumping");
1135   Symbol* name = k->name();
1136   bool created = false;
1137   _loaded_unregistered_classes.put_if_absent(name, true, &created);
1138   if (created) {
1139     MutexLocker mu_r(THREAD, Compile_lock); // add_to_hierarchy asserts this.
1140     SystemDictionary::add_to_hierarchy(k, CHECK_false);
1141   }
1142   return created;
1143 }
1144 
1145 void SystemDictionaryShared::add_replaced_class(InstanceKlass* k, TRAPS) {
1146   Arguments::assert_is_dumping_archive();
1147   assert(!k->is_loaded(), "Invariant");
1148   {
1149     MutexLocker mu_r(THREAD, Compile_lock); // add_to_hierarchy asserts this.
1150     SystemDictionary::add_to_hierarchy(k, CHECK);
1151   }
1152 }
1153 
1154 // This function is called to resolve the super/interfaces of shared classes for
1155 // non-built-in loaders. E.g., ChildClass in the below example
1156 // where "super:" (and optionally "interface:") have been specified.
1157 //
1158 // java/lang/Object id: 0
1159 // Interface   id: 2 super: 0 source: cust.jar
1160 // ChildClass  id: 4 super: 0 interfaces: 2 source: cust.jar
1161 InstanceKlass* SystemDictionaryShared::dump_time_resolve_super_or_fail(
1162     Symbol* child_name, Symbol* class_name, Handle class_loader,
1163     Handle protection_domain, bool is_superclass, TRAPS) {
1164 
1165   assert(DumpSharedSpaces, "only when dumping");
1166 
1167   ClassListParser* parser = ClassListParser::instance();
1168   if (parser == NULL) {
1169     // We're still loading the well-known classes, before the ClassListParser is created.
1170     return NULL;
1171   }
1172   if (child_name->equals(parser->current_class_name())) {
1173     // When this function is called, all the numbered super and interface types


1372   } else {
1373     guarantee(k->is_shared_unregistered_class(),
1374               "Class loader type must not be set for UNREGISTERED class %s", name);
1375   }
1376 }
1377 
1378 class ExcludeDumpTimeSharedClasses : StackObj {
1379 public:
1380   bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
1381     if (SystemDictionaryShared::should_be_excluded(k)) {
1382       info.set_excluded();
1383     }
1384     return true; // keep on iterating
1385   }
1386 };
1387 
1388 void SystemDictionaryShared::check_excluded_classes() {
1389   ExcludeDumpTimeSharedClasses excl;
1390   _dumptime_table->iterate(&excl);
1391   _dumptime_table->update_counts();
1392 }
1393 
1394 void SystemDictionaryShared::set_excluded(InstanceKlass* k) {
1395   Arguments::assert_is_dumping_archive();
1396   find_or_allocate_info_for(k)->set_excluded();
1397 }
1398 
1399 bool SystemDictionaryShared::is_excluded_class(InstanceKlass* k) {
1400   assert(_no_class_loading_should_happen, "sanity");
1401   Arguments::assert_is_dumping_archive();
1402   return find_or_allocate_info_for(k)->is_excluded();
1403 }
1404 
1405 void SystemDictionaryShared::set_class_has_failed_verification(InstanceKlass* ik) {
1406   Arguments::assert_is_dumping_archive();
1407   find_or_allocate_info_for(ik)->set_failed_verification();
1408 }
1409 
1410 bool SystemDictionaryShared::has_class_failed_verification(InstanceKlass* ik) {
1411   Arguments::assert_is_dumping_archive();
1412   if (_dumptime_table == NULL) {
1413     assert(DynamicDumpSharedSpaces, "sanity");
1414     assert(ik->is_shared(), "must be a shared class in the static archive");
1415     return false;
1416   }


< prev index next >