< prev index next >

src/share/vm/classfile/loaderConstraints.cpp

Print this page




  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoaderData.inline.hpp"
  27 #include "classfile/loaderConstraints.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "runtime/handles.inline.hpp"
  31 #include "runtime/safepoint.hpp"
  32 #include "utilities/hashtable.inline.hpp"
  33 
  34 void LoaderConstraintEntry::set_loader(int i, oop p) {
  35   set_loader_data(i, ClassLoaderData::class_loader_data(p));
  36 }
  37 
  38 LoaderConstraintTable::LoaderConstraintTable(int nof_buckets)
  39   : Hashtable<Klass*, mtClass>(nof_buckets, sizeof(LoaderConstraintEntry)) {};
  40 
  41 
  42 LoaderConstraintEntry* LoaderConstraintTable::new_entry(
  43                                  unsigned int hash, Symbol* name,
  44                                  Klass* klass, int num_loaders,
  45                                  int max_loaders) {
  46   LoaderConstraintEntry* entry;
  47   entry = (LoaderConstraintEntry*)Hashtable<Klass*, mtClass>::new_entry(hash, klass);
  48   entry->set_name(name);
  49   entry->set_num_loaders(num_loaders);
  50   entry->set_max_loaders(max_loaders);
  51   return entry;
  52 }
  53 
  54 void LoaderConstraintTable::free_entry(LoaderConstraintEntry *entry) {
  55   // decrement name refcount before freeing
  56   entry->name()->decrement_refcount();
  57   Hashtable<Klass*, mtClass>::free_entry(entry);
  58 }
  59 
  60 // Enhanced Class Redefinition support
  61 void LoaderConstraintTable::classes_do(KlassClosure* f) {
  62   for (int index = 0; index < table_size(); index++) {
  63     for (LoaderConstraintEntry* probe = bucket(index);
  64                                 probe != NULL;
  65                                 probe = probe->next()) {
  66       if (probe->klass() != NULL) {
  67         f->do_klass(probe->klass());
  68       }
  69         }
  70       }
  71     }
  72 
  73 // The loaderConstraintTable must always be accessed with the
  74 // SystemDictionary lock held. This is true even for readers as
  75 // entries in the table could be being dynamically resized.
  76 
  77 LoaderConstraintEntry** LoaderConstraintTable::find_loader_constraint(


  89         for (int i = p->num_loaders() - 1; i >= 0; i--) {
  90           if (p->loader_data(i) == loader_data) {
  91             return pp;
  92           }
  93         }
  94       }
  95     }
  96     pp = p->next_addr();
  97   }
  98   return pp;
  99 }
 100 
 101 
 102 void LoaderConstraintTable::purge_loader_constraints() {
 103   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
 104   // Remove unloaded entries from constraint table
 105   for (int index = 0; index < table_size(); index++) {
 106     LoaderConstraintEntry** p = bucket_addr(index);
 107     while(*p) {
 108       LoaderConstraintEntry* probe = *p;
 109       Klass* klass = probe->klass();
 110       // Remove klass that is no longer alive
 111       if (klass != NULL &&
 112           klass->class_loader_data()->is_unloading()) {
 113         probe->set_klass(NULL);
 114         if (log_is_enabled(Info, class, loader, constraints)) {
 115           ResourceMark rm;
 116           outputStream* out = Log(class, loader, constraints)::info_stream();
 117           out->print_cr("purging class object from constraint for name %s,"
 118                      " loader list:",
 119                      probe->name()->as_C_string());
 120           for (int i = 0; i < probe->num_loaders(); i++) {
 121             out->print_cr("    [%d]: %s", i,
 122                           probe->loader_data(i)->loader_name());
 123           }
 124         }
 125       }
 126       // Remove entries no longer alive from loader array
 127       int n = 0;
 128       while (n < probe->num_loaders()) {
 129         if (probe->loader_data(n)->is_unloading()) {


 169         // Purge entry
 170         *p = probe->next();
 171         FREE_C_HEAP_ARRAY(oop, probe->loaders());
 172         free_entry(probe);
 173       } else {
 174 #ifdef ASSERT
 175         if (probe->klass() != NULL) {
 176           ClassLoaderData* loader_data =
 177             probe->klass()->class_loader_data();
 178           assert(!loader_data->is_unloading(), "klass should be live");
 179         }
 180 #endif
 181         // Go to next entry
 182         p = probe->next_addr();
 183       }
 184     }
 185   }
 186 }
 187 
 188 bool LoaderConstraintTable::add_entry(Symbol* class_name,
 189                                       Klass* klass1, Handle class_loader1,
 190                                       Klass* klass2, Handle class_loader2) {
 191   int failure_code = 0; // encode different reasons for failing
 192 
 193   if (klass1 != NULL && klass2 != NULL && klass1 != klass2) {
 194     failure_code = 1;
 195   } else {
 196     Klass* klass = klass1 != NULL ? klass1 : klass2;
 197 
 198     LoaderConstraintEntry** pp1 = find_loader_constraint(class_name,
 199                                                          class_loader1);
 200     if (*pp1 != NULL && (*pp1)->klass() != NULL) {
 201       if (klass != NULL) {
 202         if (klass != (*pp1)->klass()) {
 203           failure_code = 2;
 204         }
 205       } else {
 206         klass = (*pp1)->klass();
 207       }
 208     }
 209 
 210     LoaderConstraintEntry** pp2 = find_loader_constraint(class_name,
 211                                                          class_loader2);
 212     if (*pp2 != NULL && (*pp2)->klass() != NULL) {
 213       if (klass != NULL) {
 214         if (klass != (*pp2)->klass()) {
 215           failure_code = 3;
 216         }


 278               " the stored class object in the constraint"; break;
 279     case 3: reason = "the class object presented by loader[1] does not match"
 280               " the stored class object in the constraint"; break;
 281     default: reason = "unknown reason code";
 282     }
 283     out->print_cr("failed to add constraint for name: %s, loader[0]: %s,"
 284                " loader[1]: %s, Reason: %s",
 285                class_name->as_C_string(),
 286                SystemDictionary::loader_name(class_loader1()),
 287                SystemDictionary::loader_name(class_loader2()),
 288                reason
 289                );
 290   }
 291 
 292   return failure_code == 0;
 293 }
 294 
 295 
 296 // return true if the constraint was updated, false if the constraint is
 297 // violated
 298 bool LoaderConstraintTable::check_or_update(instanceKlassHandle k,
 299                                                    Handle loader,
 300                                                    Symbol* name) {
 301   LoaderConstraintEntry* p = *(find_loader_constraint(name, loader));
 302   if (p && p->klass() != NULL && p->klass() != k()) {
 303     if (log_is_enabled(Info, class, loader, constraints)) {
 304       ResourceMark rm;
 305       outputStream* out = Log(class, loader, constraints)::info_stream();
 306       out->print_cr("constraint check failed for name %s, loader %s: "
 307                  "the presented class object differs from that stored",
 308                  name->as_C_string(),
 309                  SystemDictionary::loader_name(loader()));
 310     }
 311     return false;
 312   } else {
 313     if (p && p->klass() == NULL) {
 314       p->set_klass(k());
 315       if (log_is_enabled(Info, class, loader, constraints)) {
 316         ResourceMark rm;
 317         outputStream* out = Log(class, loader, constraints)::info_stream();
 318         out->print_cr("updating constraint for name %s, loader %s, "
 319                    "by setting class object",
 320                    name->as_C_string(),
 321                    SystemDictionary::loader_name(loader()));
 322       }
 323     }
 324     return true;
 325   }
 326 }
 327 
 328 Klass* LoaderConstraintTable::find_constrained_klass(Symbol* name,
 329                                                        Handle loader) {
 330   LoaderConstraintEntry *p = *(find_loader_constraint(name, loader));
 331   if (p != NULL && p->klass() != NULL) {
 332     if (p->klass()->is_instance_klass() && !InstanceKlass::cast(p->klass())->is_loaded()) {

 333       // Only return fully loaded classes.  Classes found through the
 334       // constraints might still be in the process of loading.
 335       return NULL;
 336     }
 337     return p->klass();
 338   }
 339 
 340   // No constraints, or else no klass loaded yet.
 341   return NULL;
 342 }
 343 
 344 void LoaderConstraintTable::ensure_loader_constraint_capacity(
 345                                                      LoaderConstraintEntry *p,
 346                                                     int nfree) {
 347     if (p->max_loaders() - p->num_loaders() < nfree) {
 348         int n = nfree + p->num_loaders();
 349         ClassLoaderData** new_loaders = NEW_C_HEAP_ARRAY(ClassLoaderData*, n, mtClass);
 350         memcpy(new_loaders, p->loaders(), sizeof(ClassLoaderData*) * p->num_loaders());
 351         p->set_max_loaders(n);
 352         FREE_C_HEAP_ARRAY(ClassLoaderData*, p->loaders());
 353         p->set_loaders(new_loaders);
 354     }
 355 }
 356 
 357 
 358 void LoaderConstraintTable::extend_loader_constraint(LoaderConstraintEntry* p,
 359                                                      Handle loader,
 360                                                      Klass* klass) {
 361   ensure_loader_constraint_capacity(p, 1);
 362   int num = p->num_loaders();
 363   p->set_loader(num, loader());
 364   p->set_num_loaders(num + 1);
 365   if (log_is_enabled(Info, class, loader, constraints)) {
 366     ResourceMark rm;
 367     outputStream* out = Log(class, loader, constraints)::info_stream();
 368     out->print_cr("extending constraint for name %s by adding loader[%d]: %s %s",
 369                p->name()->as_C_string(),
 370                num,
 371                SystemDictionary::loader_name(loader()),
 372                (p->klass() == NULL ? " and setting class object" : "")
 373                );
 374   }
 375   if (p->klass() == NULL) {
 376     p->set_klass(klass);
 377   } else {
 378     assert(klass == NULL || p->klass() == klass, "constraints corrupted");
 379   }
 380 }
 381 
 382 
 383 void LoaderConstraintTable::merge_loader_constraints(
 384                                                    LoaderConstraintEntry** pp1,
 385                                                    LoaderConstraintEntry** pp2,
 386                                                    Klass* klass) {
 387   // make sure *pp1 has higher capacity
 388   if ((*pp1)->max_loaders() < (*pp2)->max_loaders()) {
 389     LoaderConstraintEntry** tmp = pp2;
 390     pp2 = pp1;
 391     pp1 = tmp;
 392   }
 393 
 394   LoaderConstraintEntry* p1 = *pp1;
 395   LoaderConstraintEntry* p2 = *pp2;
 396 
 397   ensure_loader_constraint_capacity(p1, p2->num_loaders());
 398 
 399   for (int i = 0; i < p2->num_loaders(); i++) {
 400     int num = p1->num_loaders();
 401     p1->set_loader_data(num, p2->loader_data(i));
 402     p1->set_num_loaders(num + 1);
 403   }
 404 
 405   if (log_is_enabled(Info, class, loader, constraints)) {
 406     ResourceMark rm;


 430     p1->set_klass(klass);
 431   } else {
 432     assert(p1->klass() == klass, "constraints corrupted");
 433   }
 434 
 435   *pp2 = p2->next();
 436   FREE_C_HEAP_ARRAY(oop, p2->loaders());
 437   free_entry(p2);
 438   return;
 439 }
 440 
 441 
 442 void LoaderConstraintTable::verify(Dictionary* dictionary,
 443                                    PlaceholderTable* placeholders) {
 444   Thread *thread = Thread::current();
 445   for (int cindex = 0; cindex < _loader_constraint_size; cindex++) {
 446     for (LoaderConstraintEntry* probe = bucket(cindex);
 447                                 probe != NULL;
 448                                 probe = probe->next()) {
 449       if (probe->klass() != NULL) {
 450         InstanceKlass* ik = InstanceKlass::cast(probe->klass());
 451         guarantee(ik->name() == probe->name(), "name should match");
 452         Symbol* name = ik->name();
 453         ClassLoaderData* loader_data = ik->class_loader_data();
 454         unsigned int d_hash = dictionary->compute_hash(name, loader_data);
 455         int d_index = dictionary->hash_to_index(d_hash);
 456         Klass* k = dictionary->find_class(d_index, d_hash, name, loader_data);
 457         if (k != NULL) {
 458           // We found the class in the system dictionary, so we should
 459           // make sure that the Klass* matches what we already have.
 460           guarantee(k == probe->klass(), "klass should be in dictionary");
 461         } else {
 462           // If we don't find the class in the system dictionary, it
 463           // has to be in the placeholders table.
 464           unsigned int p_hash = placeholders->compute_hash(name, loader_data);
 465           int p_index = placeholders->hash_to_index(p_hash);
 466           PlaceholderEntry* entry = placeholders->get_entry(p_index, p_hash,
 467                                                             name, loader_data);
 468 
 469           // The InstanceKlass might not be on the entry, so the only
 470           // thing we can check here is whether we were successful in
 471           // finding the class in the placeholders table.
 472           guarantee(entry != NULL, "klass should be in the placeholders");
 473         }
 474       }
 475       for (int n = 0; n< probe->num_loaders(); n++) {
 476         assert(ClassLoaderDataGraph::contains_loader_data(probe->loader_data(n)), "The loader is missing");




  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/classLoaderData.inline.hpp"
  27 #include "classfile/loaderConstraints.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "runtime/handles.inline.hpp"
  31 #include "runtime/safepoint.hpp"
  32 #include "utilities/hashtable.inline.hpp"
  33 
  34 void LoaderConstraintEntry::set_loader(int i, oop p) {
  35   set_loader_data(i, ClassLoaderData::class_loader_data(p));
  36 }
  37 
  38 LoaderConstraintTable::LoaderConstraintTable(int nof_buckets)
  39   : Hashtable<InstanceKlass*, mtClass>(nof_buckets, sizeof(LoaderConstraintEntry)) {};
  40 
  41 
  42 LoaderConstraintEntry* LoaderConstraintTable::new_entry(
  43                                  unsigned int hash, Symbol* name,
  44                                  InstanceKlass* klass, int num_loaders,
  45                                  int max_loaders) {
  46   LoaderConstraintEntry* entry;
  47   entry = (LoaderConstraintEntry*)Hashtable<InstanceKlass*, mtClass>::new_entry(hash, klass);
  48   entry->set_name(name);
  49   entry->set_num_loaders(num_loaders);
  50   entry->set_max_loaders(max_loaders);
  51   return entry;
  52 }
  53 
  54 void LoaderConstraintTable::free_entry(LoaderConstraintEntry *entry) {
  55   // decrement name refcount before freeing
  56   entry->name()->decrement_refcount();
  57   Hashtable<InstanceKlass*, mtClass>::free_entry(entry);
  58 }
  59 
  60 // Enhanced Class Redefinition support
  61 void LoaderConstraintTable::classes_do(KlassClosure* f) {
  62   for (int index = 0; index < table_size(); index++) {
  63     for (LoaderConstraintEntry* probe = bucket(index);
  64                                 probe != NULL;
  65                                 probe = probe->next()) {
  66       if (probe->klass() != NULL) {
  67         f->do_klass(probe->klass());
  68       }
  69         }
  70       }
  71     }
  72 
  73 // The loaderConstraintTable must always be accessed with the
  74 // SystemDictionary lock held. This is true even for readers as
  75 // entries in the table could be being dynamically resized.
  76 
  77 LoaderConstraintEntry** LoaderConstraintTable::find_loader_constraint(


  89         for (int i = p->num_loaders() - 1; i >= 0; i--) {
  90           if (p->loader_data(i) == loader_data) {
  91             return pp;
  92           }
  93         }
  94       }
  95     }
  96     pp = p->next_addr();
  97   }
  98   return pp;
  99 }
 100 
 101 
 102 void LoaderConstraintTable::purge_loader_constraints() {
 103   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
 104   // Remove unloaded entries from constraint table
 105   for (int index = 0; index < table_size(); index++) {
 106     LoaderConstraintEntry** p = bucket_addr(index);
 107     while(*p) {
 108       LoaderConstraintEntry* probe = *p;
 109       InstanceKlass* klass = probe->klass();
 110       // Remove klass that is no longer alive
 111       if (klass != NULL &&
 112           klass->class_loader_data()->is_unloading()) {
 113         probe->set_klass(NULL);
 114         if (log_is_enabled(Info, class, loader, constraints)) {
 115           ResourceMark rm;
 116           outputStream* out = Log(class, loader, constraints)::info_stream();
 117           out->print_cr("purging class object from constraint for name %s,"
 118                      " loader list:",
 119                      probe->name()->as_C_string());
 120           for (int i = 0; i < probe->num_loaders(); i++) {
 121             out->print_cr("    [%d]: %s", i,
 122                           probe->loader_data(i)->loader_name());
 123           }
 124         }
 125       }
 126       // Remove entries no longer alive from loader array
 127       int n = 0;
 128       while (n < probe->num_loaders()) {
 129         if (probe->loader_data(n)->is_unloading()) {


 169         // Purge entry
 170         *p = probe->next();
 171         FREE_C_HEAP_ARRAY(oop, probe->loaders());
 172         free_entry(probe);
 173       } else {
 174 #ifdef ASSERT
 175         if (probe->klass() != NULL) {
 176           ClassLoaderData* loader_data =
 177             probe->klass()->class_loader_data();
 178           assert(!loader_data->is_unloading(), "klass should be live");
 179         }
 180 #endif
 181         // Go to next entry
 182         p = probe->next_addr();
 183       }
 184     }
 185   }
 186 }
 187 
 188 bool LoaderConstraintTable::add_entry(Symbol* class_name,
 189                                       InstanceKlass* klass1, Handle class_loader1,
 190                                       InstanceKlass* klass2, Handle class_loader2) {
 191   int failure_code = 0; // encode different reasons for failing
 192 
 193   if (klass1 != NULL && klass2 != NULL && klass1 != klass2) {
 194     failure_code = 1;
 195   } else {
 196     InstanceKlass* klass = klass1 != NULL ? klass1 : klass2;
 197 
 198     LoaderConstraintEntry** pp1 = find_loader_constraint(class_name,
 199                                                          class_loader1);
 200     if (*pp1 != NULL && (*pp1)->klass() != NULL) {
 201       if (klass != NULL) {
 202         if (klass != (*pp1)->klass()) {
 203           failure_code = 2;
 204         }
 205       } else {
 206         klass = (*pp1)->klass();
 207       }
 208     }
 209 
 210     LoaderConstraintEntry** pp2 = find_loader_constraint(class_name,
 211                                                          class_loader2);
 212     if (*pp2 != NULL && (*pp2)->klass() != NULL) {
 213       if (klass != NULL) {
 214         if (klass != (*pp2)->klass()) {
 215           failure_code = 3;
 216         }


 278               " the stored class object in the constraint"; break;
 279     case 3: reason = "the class object presented by loader[1] does not match"
 280               " the stored class object in the constraint"; break;
 281     default: reason = "unknown reason code";
 282     }
 283     out->print_cr("failed to add constraint for name: %s, loader[0]: %s,"
 284                " loader[1]: %s, Reason: %s",
 285                class_name->as_C_string(),
 286                SystemDictionary::loader_name(class_loader1()),
 287                SystemDictionary::loader_name(class_loader2()),
 288                reason
 289                );
 290   }
 291 
 292   return failure_code == 0;
 293 }
 294 
 295 
 296 // return true if the constraint was updated, false if the constraint is
 297 // violated
 298 bool LoaderConstraintTable::check_or_update(InstanceKlass* k,
 299                                             Handle loader,
 300                                             Symbol* name) {
 301   LoaderConstraintEntry* p = *(find_loader_constraint(name, loader));
 302   if (p && p->klass() != NULL && p->klass() != k) {
 303     if (log_is_enabled(Info, class, loader, constraints)) {
 304       ResourceMark rm;
 305       outputStream* out = Log(class, loader, constraints)::info_stream();
 306       out->print_cr("constraint check failed for name %s, loader %s: "
 307                  "the presented class object differs from that stored",
 308                  name->as_C_string(),
 309                  SystemDictionary::loader_name(loader()));
 310     }
 311     return false;
 312   } else {
 313     if (p && p->klass() == NULL) {
 314       p->set_klass(k);
 315       if (log_is_enabled(Info, class, loader, constraints)) {
 316         ResourceMark rm;
 317         outputStream* out = Log(class, loader, constraints)::info_stream();
 318         out->print_cr("updating constraint for name %s, loader %s, "
 319                    "by setting class object",
 320                    name->as_C_string(),
 321                    SystemDictionary::loader_name(loader()));
 322       }
 323     }
 324     return true;
 325   }
 326 }
 327 
 328 InstanceKlass* LoaderConstraintTable::find_constrained_klass(Symbol* name,
 329                                                        Handle loader) {
 330   LoaderConstraintEntry *p = *(find_loader_constraint(name, loader));
 331   if (p != NULL && p->klass() != NULL) {
 332     assert(p->klass()->is_instance_klass(), "sanity");
 333     if (p->klass()->is_loaded()) {
 334       // Only return fully loaded classes.  Classes found through the
 335       // constraints might still be in the process of loading.
 336       return NULL;
 337     }
 338     return p->klass();
 339   }
 340 
 341   // No constraints, or else no klass loaded yet.
 342   return NULL;
 343 }
 344 
 345 void LoaderConstraintTable::ensure_loader_constraint_capacity(
 346                                                      LoaderConstraintEntry *p,
 347                                                     int nfree) {
 348     if (p->max_loaders() - p->num_loaders() < nfree) {
 349         int n = nfree + p->num_loaders();
 350         ClassLoaderData** new_loaders = NEW_C_HEAP_ARRAY(ClassLoaderData*, n, mtClass);
 351         memcpy(new_loaders, p->loaders(), sizeof(ClassLoaderData*) * p->num_loaders());
 352         p->set_max_loaders(n);
 353         FREE_C_HEAP_ARRAY(ClassLoaderData*, p->loaders());
 354         p->set_loaders(new_loaders);
 355     }
 356 }
 357 
 358 
 359 void LoaderConstraintTable::extend_loader_constraint(LoaderConstraintEntry* p,
 360                                                      Handle loader,
 361                                                      InstanceKlass* klass) {
 362   ensure_loader_constraint_capacity(p, 1);
 363   int num = p->num_loaders();
 364   p->set_loader(num, loader());
 365   p->set_num_loaders(num + 1);
 366   if (log_is_enabled(Info, class, loader, constraints)) {
 367     ResourceMark rm;
 368     outputStream* out = Log(class, loader, constraints)::info_stream();
 369     out->print_cr("extending constraint for name %s by adding loader[%d]: %s %s",
 370                p->name()->as_C_string(),
 371                num,
 372                SystemDictionary::loader_name(loader()),
 373                (p->klass() == NULL ? " and setting class object" : "")
 374                );
 375   }
 376   if (p->klass() == NULL) {
 377     p->set_klass(klass);
 378   } else {
 379     assert(klass == NULL || p->klass() == klass, "constraints corrupted");
 380   }
 381 }
 382 
 383 
 384 void LoaderConstraintTable::merge_loader_constraints(
 385                                                    LoaderConstraintEntry** pp1,
 386                                                    LoaderConstraintEntry** pp2,
 387                                                    InstanceKlass* klass) {
 388   // make sure *pp1 has higher capacity
 389   if ((*pp1)->max_loaders() < (*pp2)->max_loaders()) {
 390     LoaderConstraintEntry** tmp = pp2;
 391     pp2 = pp1;
 392     pp1 = tmp;
 393   }
 394 
 395   LoaderConstraintEntry* p1 = *pp1;
 396   LoaderConstraintEntry* p2 = *pp2;
 397 
 398   ensure_loader_constraint_capacity(p1, p2->num_loaders());
 399 
 400   for (int i = 0; i < p2->num_loaders(); i++) {
 401     int num = p1->num_loaders();
 402     p1->set_loader_data(num, p2->loader_data(i));
 403     p1->set_num_loaders(num + 1);
 404   }
 405 
 406   if (log_is_enabled(Info, class, loader, constraints)) {
 407     ResourceMark rm;


 431     p1->set_klass(klass);
 432   } else {
 433     assert(p1->klass() == klass, "constraints corrupted");
 434   }
 435 
 436   *pp2 = p2->next();
 437   FREE_C_HEAP_ARRAY(oop, p2->loaders());
 438   free_entry(p2);
 439   return;
 440 }
 441 
 442 
 443 void LoaderConstraintTable::verify(Dictionary* dictionary,
 444                                    PlaceholderTable* placeholders) {
 445   Thread *thread = Thread::current();
 446   for (int cindex = 0; cindex < _loader_constraint_size; cindex++) {
 447     for (LoaderConstraintEntry* probe = bucket(cindex);
 448                                 probe != NULL;
 449                                 probe = probe->next()) {
 450       if (probe->klass() != NULL) {
 451         InstanceKlass* ik = probe->klass();
 452         guarantee(ik->name() == probe->name(), "name should match");
 453         Symbol* name = ik->name();
 454         ClassLoaderData* loader_data = ik->class_loader_data();
 455         unsigned int d_hash = dictionary->compute_hash(name, loader_data);
 456         int d_index = dictionary->hash_to_index(d_hash);
 457         InstanceKlass* k = dictionary->find_class(d_index, d_hash, name, loader_data);
 458         if (k != NULL) {
 459           // We found the class in the system dictionary, so we should
 460           // make sure that the Klass* matches what we already have.
 461           guarantee(k == probe->klass(), "klass should be in dictionary");
 462         } else {
 463           // If we don't find the class in the system dictionary, it
 464           // has to be in the placeholders table.
 465           unsigned int p_hash = placeholders->compute_hash(name, loader_data);
 466           int p_index = placeholders->hash_to_index(p_hash);
 467           PlaceholderEntry* entry = placeholders->get_entry(p_index, p_hash,
 468                                                             name, loader_data);
 469 
 470           // The InstanceKlass might not be on the entry, so the only
 471           // thing we can check here is whether we were successful in
 472           // finding the class in the placeholders table.
 473           guarantee(entry != NULL, "klass should be in the placeholders");
 474         }
 475       }
 476       for (int n = 0; n< probe->num_loaders(); n++) {
 477         assert(ClassLoaderDataGraph::contains_loader_data(probe->loader_data(n)), "The loader is missing");


< prev index next >