< prev index next >

src/share/vm/classfile/packageEntry.cpp

Print this page




  81       ResourceMark rm;
  82       assert(name() != NULL, "PackageEntry without a valid name");
  83       log_trace(modules)("PackageEntry::set_export_walk_required(): package %s defined in module %s, exports list must be walked",
  84                          name()->as_C_string(),
  85                          (this_pkg_mod == NULL || this_pkg_mod->name() == NULL) ?
  86                            UNNAMED_MODULE : this_pkg_mod->name()->as_C_string());
  87     }
  88   }
  89 }
  90 
  91 // Set the package's exported states based on the value of the ModuleEntry.
  92 void PackageEntry::set_exported(ModuleEntry* m) {
  93   MutexLocker m1(Module_lock);
  94   if (is_unqual_exported()) {
  95     // An exception could be thrown, but choose to simply ignore.
  96     // Illegal to convert an unqualified exported package to be qualifiedly exported
  97     return;
  98   }
  99 
 100   if (m == NULL) {
 101     // NULL indicates the package is being unqualifiedly exported
 102     if (has_qual_exports_list()) {
 103       // Legit to transition a package from being qualifiedly exported
 104       // to unqualified.  Clean up the qualified lists at the next
 105       // safepoint.
 106       _exported_pending_delete = _qualified_exports;
 107     }
 108 
 109     // Mark package as unqualifiedly exported
 110     set_unqual_exported();
 111 
 112   } else {
 113     // Add the exported module
 114     add_qexport(m);
 115   }
 116 }
 117 
 118 void PackageEntry::set_is_exported_allUnnamed() {
 119   MutexLocker m1(Module_lock);
 120   if (!is_unqual_exported()) {
 121    _is_exported_allUnnamed = true;
 122   }
 123 }
 124 
 125 // Remove dead module entries within the package's exported list.
 126 void PackageEntry::purge_qualified_exports() {
 127   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
 128   if (_must_walk_exports &&
 129       _qualified_exports != NULL &&
 130       !_qualified_exports->is_empty()) {
 131     ModuleEntry* pkg_module = module();


 143                          (pkg_mod == NULL || pkg_mod->name() == NULL) ? UNNAMED_MODULE : pkg_mod->name()->as_C_string());
 144     }
 145 
 146     // Go backwards because this removes entries that are dead.
 147     int len = _qualified_exports->length();
 148     for (int idx = len - 1; idx >= 0; idx--) {
 149       ModuleEntry* module_idx = _qualified_exports->at(idx);
 150       ClassLoaderData* cld_idx = module_idx->loader_data();
 151       if (cld_idx->is_unloading()) {
 152         _qualified_exports->delete_at(idx);
 153       } else {
 154         // Update the need to walk this package's exports based on live modules
 155         set_export_walk_required(cld_idx);
 156       }
 157     }
 158   }
 159 }
 160 
 161 void PackageEntry::delete_qualified_exports() {
 162   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
 163   if (_exported_pending_delete != NULL) {
 164     // If a transition occurred from qualified to unqualified, the _qualified_exports
 165     // field should have been NULL'ed out.
 166     assert(_qualified_exports == NULL, "Package's exported pending delete, exported list should not be active");
 167     delete _exported_pending_delete;
 168   }
 169 
 170   if (_qualified_exports != NULL) {
 171     delete _qualified_exports;
 172   }
 173 
 174   _exported_pending_delete = NULL;
 175   _qualified_exports = NULL;
 176 }
 177 
 178 PackageEntryTable::PackageEntryTable(int table_size)
 179   : Hashtable<Symbol*, mtModule>(table_size, sizeof(PackageEntry))
 180 {
 181 }
 182 
 183 PackageEntryTable::~PackageEntryTable() {
 184   assert_locked_or_safepoint(Module_lock);
 185 
 186   // Walk through all buckets and all entries in each bucket,
 187   // freeing each entry.
 188   for (int i = 0; i < table_size(); ++i) {
 189     for (PackageEntry* p = bucket(i); p != NULL;) {
 190       PackageEntry* to_remove = p;
 191       // read next before freeing.
 192       p = p->next();
 193 
 194       // Clean out the C heap allocated qualified exports list first before freeing the entry
 195       to_remove->delete_qualified_exports();
 196       to_remove->name()->decrement_refcount();
 197 
 198       // Unlink from the Hashtable prior to freeing
 199       unlink_entry(to_remove);
 200       FREE_C_HEAP_ARRAY(char, to_remove);
 201     }
 202   }
 203   assert(number_of_entries() == 0, "should have removed all entries");
 204   assert(new_entry_free_list() == NULL, "entry present on PackageEntryTable's free list");


 285 void PackageEntryTable::verify_javabase_packages(GrowableArray<Symbol*> *pkg_list) {
 286   for (int i = 0; i < table_size(); i++) {
 287     for (PackageEntry* entry = bucket(i);
 288                        entry != NULL;
 289                        entry = entry->next()) {
 290       ModuleEntry* m = entry->module();
 291       Symbol* module_name = (m == NULL ? NULL : m->name());
 292       if (module_name != NULL &&
 293           (module_name->fast_compare(vmSymbols::java_base()) == 0) &&
 294           !pkg_list->contains(entry->name())) {
 295         ResourceMark rm;
 296         vm_exit_during_initialization("A non-" JAVA_BASE_NAME " package was loaded prior to module system initialization", entry->name()->as_C_string());
 297       }
 298     }
 299   }
 300 
 301 }
 302 
 303 // iteration of qualified exports
 304 void PackageEntry::package_exports_do(ModuleClosure* const f) {
 305   assert_locked_or_safepoint(Module_lock);
 306   assert(f != NULL, "invariant");
 307 
 308   if (has_qual_exports_list()) {
 309     int qe_len = _qualified_exports->length();
 310 
 311     for (int i = 0; i < qe_len; ++i) {
 312       f->do_module(_qualified_exports->at(i));
 313     }
 314   }
 315 }
 316 
 317 // Remove dead entries from all packages' exported list
 318 void PackageEntryTable::purge_all_package_exports() {
 319   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
 320   for (int i = 0; i < table_size(); i++) {
 321     for (PackageEntry* entry = bucket(i);
 322                        entry != NULL;
 323                        entry = entry->next()) {
 324       if (entry->exported_pending_delete()) {
 325         // exported list is pending deletion due to a transition
 326         // from qualified to unqualified
 327         entry->delete_qualified_exports();
 328       } else if (entry->is_qual_exported()) {
 329         entry->purge_qualified_exports();
 330       }




  81       ResourceMark rm;
  82       assert(name() != NULL, "PackageEntry without a valid name");
  83       log_trace(modules)("PackageEntry::set_export_walk_required(): package %s defined in module %s, exports list must be walked",
  84                          name()->as_C_string(),
  85                          (this_pkg_mod == NULL || this_pkg_mod->name() == NULL) ?
  86                            UNNAMED_MODULE : this_pkg_mod->name()->as_C_string());
  87     }
  88   }
  89 }
  90 
  91 // Set the package's exported states based on the value of the ModuleEntry.
  92 void PackageEntry::set_exported(ModuleEntry* m) {
  93   MutexLocker m1(Module_lock);
  94   if (is_unqual_exported()) {
  95     // An exception could be thrown, but choose to simply ignore.
  96     // Illegal to convert an unqualified exported package to be qualifiedly exported
  97     return;
  98   }
  99 
 100   if (m == NULL) {
 101     // NULL indicates the package is being unqualifiedly exported.  Clean up
 102     // the qualified list at the next safepoint.







 103     set_unqual_exported();

 104   } else {
 105     // Add the exported module
 106     add_qexport(m);
 107   }
 108 }
 109 
 110 void PackageEntry::set_is_exported_allUnnamed() {
 111   MutexLocker m1(Module_lock);
 112   if (!is_unqual_exported()) {
 113    _is_exported_allUnnamed = true;
 114   }
 115 }
 116 
 117 // Remove dead module entries within the package's exported list.
 118 void PackageEntry::purge_qualified_exports() {
 119   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
 120   if (_must_walk_exports &&
 121       _qualified_exports != NULL &&
 122       !_qualified_exports->is_empty()) {
 123     ModuleEntry* pkg_module = module();


 135                          (pkg_mod == NULL || pkg_mod->name() == NULL) ? UNNAMED_MODULE : pkg_mod->name()->as_C_string());
 136     }
 137 
 138     // Go backwards because this removes entries that are dead.
 139     int len = _qualified_exports->length();
 140     for (int idx = len - 1; idx >= 0; idx--) {
 141       ModuleEntry* module_idx = _qualified_exports->at(idx);
 142       ClassLoaderData* cld_idx = module_idx->loader_data();
 143       if (cld_idx->is_unloading()) {
 144         _qualified_exports->delete_at(idx);
 145       } else {
 146         // Update the need to walk this package's exports based on live modules
 147         set_export_walk_required(cld_idx);
 148       }
 149     }
 150   }
 151 }
 152 
 153 void PackageEntry::delete_qualified_exports() {
 154   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");







 155   if (_qualified_exports != NULL) {
 156     delete _qualified_exports;
 157   }


 158   _qualified_exports = NULL;
 159 }
 160 
 161 PackageEntryTable::PackageEntryTable(int table_size)
 162   : Hashtable<Symbol*, mtModule>(table_size, sizeof(PackageEntry))
 163 {
 164 }
 165 
 166 PackageEntryTable::~PackageEntryTable() {
 167   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
 168 
 169   // Walk through all buckets and all entries in each bucket,
 170   // freeing each entry.
 171   for (int i = 0; i < table_size(); ++i) {
 172     for (PackageEntry* p = bucket(i); p != NULL;) {
 173       PackageEntry* to_remove = p;
 174       // read next before freeing.
 175       p = p->next();
 176 
 177       // Clean out the C heap allocated qualified exports list first before freeing the entry
 178       to_remove->delete_qualified_exports();
 179       to_remove->name()->decrement_refcount();
 180 
 181       // Unlink from the Hashtable prior to freeing
 182       unlink_entry(to_remove);
 183       FREE_C_HEAP_ARRAY(char, to_remove);
 184     }
 185   }
 186   assert(number_of_entries() == 0, "should have removed all entries");
 187   assert(new_entry_free_list() == NULL, "entry present on PackageEntryTable's free list");


 268 void PackageEntryTable::verify_javabase_packages(GrowableArray<Symbol*> *pkg_list) {
 269   for (int i = 0; i < table_size(); i++) {
 270     for (PackageEntry* entry = bucket(i);
 271                        entry != NULL;
 272                        entry = entry->next()) {
 273       ModuleEntry* m = entry->module();
 274       Symbol* module_name = (m == NULL ? NULL : m->name());
 275       if (module_name != NULL &&
 276           (module_name->fast_compare(vmSymbols::java_base()) == 0) &&
 277           !pkg_list->contains(entry->name())) {
 278         ResourceMark rm;
 279         vm_exit_during_initialization("A non-" JAVA_BASE_NAME " package was loaded prior to module system initialization", entry->name()->as_C_string());
 280       }
 281     }
 282   }
 283 
 284 }
 285 
 286 // iteration of qualified exports
 287 void PackageEntry::package_exports_do(ModuleClosure* const f) {

 288   assert(f != NULL, "invariant");

 289   if (has_qual_exports_list()) {
 290     int qe_len = _qualified_exports->length();

 291     for (int i = 0; i < qe_len; ++i) {
 292       f->do_module(_qualified_exports->at(i));
 293     }
 294   }
 295 }
 296 
 297 // Remove dead entries from all packages' exported list
 298 void PackageEntryTable::purge_all_package_exports() {
 299   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
 300   for (int i = 0; i < table_size(); i++) {
 301     for (PackageEntry* entry = bucket(i);
 302                        entry != NULL;
 303                        entry = entry->next()) {
 304       if (entry->exported_pending_delete()) {
 305         // exported list is pending deletion due to a transition
 306         // from qualified to unqualified
 307         entry->delete_qualified_exports();
 308       } else if (entry->is_qual_exported()) {
 309         entry->purge_qualified_exports();
 310       }


< prev index next >