hotspot/src/share/vm/classfile/systemDictionary.cpp
changeset 14488 ab48109f7d1b
parent 14077 a7060dec741b
child 14588 8ec26d2d9339
equal deleted inserted replaced
14486:7d079e0eedef 14488:ab48109f7d1b
   238     k = SystemDictionary::resolve_instance_class_or_null(fd.object_key(),
   238     k = SystemDictionary::resolve_instance_class_or_null(fd.object_key(),
   239                                                          class_loader,
   239                                                          class_loader,
   240                                                          protection_domain,
   240                                                          protection_domain,
   241                                                          CHECK_NULL);
   241                                                          CHECK_NULL);
   242     if (k != NULL) {
   242     if (k != NULL) {
   243       k = Klass::cast(k)->array_klass(fd.dimension(), CHECK_NULL);
   243       k = k->array_klass(fd.dimension(), CHECK_NULL);
   244     }
   244     }
   245   } else {
   245   } else {
   246     k = Universe::typeArrayKlassObj(t);
   246     k = Universe::typeArrayKlassObj(t);
   247     k = TypeArrayKlass::cast(k)->array_klass(fd.dimension(), CHECK_NULL);
   247     k = TypeArrayKlass::cast(k)->array_klass(fd.dimension(), CHECK_NULL);
   248   }
   248   }
   326     // so we don't throw an exception here.
   326     // so we don't throw an exception here.
   327     // see: nsk redefclass014 & java.lang.instrument Instrument032
   327     // see: nsk redefclass014 & java.lang.instrument Instrument032
   328     if ((childk != NULL ) && (is_superclass) &&
   328     if ((childk != NULL ) && (is_superclass) &&
   329        ((quicksuperk = InstanceKlass::cast(childk)->super()) != NULL) &&
   329        ((quicksuperk = InstanceKlass::cast(childk)->super()) != NULL) &&
   330 
   330 
   331          ((Klass::cast(quicksuperk)->name() == class_name) &&
   331          ((quicksuperk->name() == class_name) &&
   332             (Klass::cast(quicksuperk)->class_loader()  == class_loader()))) {
   332             (quicksuperk->class_loader()  == class_loader()))) {
   333            return quicksuperk;
   333            return quicksuperk;
   334     } else {
   334     } else {
   335       PlaceholderEntry* probe = placeholders()->get_entry(p_index, p_hash, child_name, loader_data);
   335       PlaceholderEntry* probe = placeholders()->get_entry(p_index, p_hash, child_name, loader_data);
   336       if (probe && probe->check_seen_thread(THREAD, PlaceholderTable::LOAD_SUPER)) {
   336       if (probe && probe->check_seen_thread(THREAD, PlaceholderTable::LOAD_SUPER)) {
   337           throw_circularity_error = true;
   337           throw_circularity_error = true;
   926       k = Universe::typeArrayKlassObj(t);
   926       k = Universe::typeArrayKlassObj(t);
   927     } else {
   927     } else {
   928       k = SystemDictionary::find(fd.object_key(), class_loader, protection_domain, THREAD);
   928       k = SystemDictionary::find(fd.object_key(), class_loader, protection_domain, THREAD);
   929     }
   929     }
   930     if (k != NULL) {
   930     if (k != NULL) {
   931       k = Klass::cast(k)->array_klass_or_null(fd.dimension());
   931       k = k->array_klass_or_null(fd.dimension());
   932     }
   932     }
   933   } else {
   933   } else {
   934     k = find(class_name, class_loader, protection_domain, THREAD);
   934     k = find(class_name, class_loader, protection_domain, THREAD);
   935   }
   935   }
   936   return k;
   936   return k;
  1535       SystemDictionary_lock->wait();
  1535       SystemDictionary_lock->wait();
  1536     }
  1536     }
  1537     // Only special cases allow parallel defines and can use other thread's results
  1537     // Only special cases allow parallel defines and can use other thread's results
  1538     // Other cases fall through, and may run into duplicate defines
  1538     // Other cases fall through, and may run into duplicate defines
  1539     // caught by finding an entry in the SystemDictionary
  1539     // caught by finding an entry in the SystemDictionary
  1540     if ((UnsyncloadClass || is_parallelDefine(class_loader)) && (probe->InstanceKlass() != NULL)) {
  1540     if ((UnsyncloadClass || is_parallelDefine(class_loader)) && (probe->instance_klass() != NULL)) {
  1541         probe->remove_seen_thread(THREAD, PlaceholderTable::DEFINE_CLASS);
  1541         probe->remove_seen_thread(THREAD, PlaceholderTable::DEFINE_CLASS);
  1542         placeholders()->find_and_remove(p_index, p_hash, name_h, loader_data, THREAD);
  1542         placeholders()->find_and_remove(p_index, p_hash, name_h, loader_data, THREAD);
  1543         SystemDictionary_lock->notify_all();
  1543         SystemDictionary_lock->notify_all();
  1544 #ifdef ASSERT
  1544 #ifdef ASSERT
  1545         Klass* check = find_class(d_index, d_hash, name_h, loader_data);
  1545         Klass* check = find_class(d_index, d_hash, name_h, loader_data);
  1546         assert(check != NULL, "definer missed recording success");
  1546         assert(check != NULL, "definer missed recording success");
  1547 #endif
  1547 #endif
  1548         return(instanceKlassHandle(THREAD, probe->InstanceKlass()));
  1548         return(instanceKlassHandle(THREAD, probe->instance_klass()));
  1549     } else {
  1549     } else {
  1550       // This thread will define the class (even if earlier thread tried and had an error)
  1550       // This thread will define the class (even if earlier thread tried and had an error)
  1551       probe->set_definer(THREAD);
  1551       probe->set_definer(THREAD);
  1552     }
  1552     }
  1553   }
  1553   }
  1564     if (probe != NULL) {
  1564     if (probe != NULL) {
  1565       if (HAS_PENDING_EXCEPTION) {
  1565       if (HAS_PENDING_EXCEPTION) {
  1566         linkage_exception = Handle(THREAD,PENDING_EXCEPTION);
  1566         linkage_exception = Handle(THREAD,PENDING_EXCEPTION);
  1567         CLEAR_PENDING_EXCEPTION;
  1567         CLEAR_PENDING_EXCEPTION;
  1568       } else {
  1568       } else {
  1569         probe->set_instanceKlass(k());
  1569         probe->set_instance_klass(k());
  1570       }
  1570       }
  1571       probe->set_definer(NULL);
  1571       probe->set_definer(NULL);
  1572       probe->remove_seen_thread(THREAD, PlaceholderTable::DEFINE_CLASS);
  1572       probe->remove_seen_thread(THREAD, PlaceholderTable::DEFINE_CLASS);
  1573       placeholders()->find_and_remove(p_index, p_hash, name_h, loader_data, THREAD);
  1573       placeholders()->find_and_remove(p_index, p_hash, name_h, loader_data, THREAD);
  1574       SystemDictionary_lock->notify_all();
  1574       SystemDictionary_lock->notify_all();
  2147       MutexLocker mu(SystemDictionary_lock, THREAD);
  2147       MutexLocker mu(SystemDictionary_lock, THREAD);
  2148       klass = constraints()->find_constrained_klass(fd.object_key(), class_loader);
  2148       klass = constraints()->find_constrained_klass(fd.object_key(), class_loader);
  2149     }
  2149     }
  2150     // If element class already loaded, allocate array klass
  2150     // If element class already loaded, allocate array klass
  2151     if (klass != NULL) {
  2151     if (klass != NULL) {
  2152       klass = Klass::cast(klass)->array_klass_or_null(fd.dimension());
  2152       klass = klass->array_klass_or_null(fd.dimension());
  2153     }
  2153     }
  2154   } else {
  2154   } else {
  2155     MutexLocker mu(SystemDictionary_lock, THREAD);
  2155     MutexLocker mu(SystemDictionary_lock, THREAD);
  2156     // Non-array classes are easy: simply check the constraint table.
  2156     // Non-array classes are easy: simply check the constraint table.
  2157     klass = constraints()->find_constrained_klass(class_name, class_loader);
  2157     klass = constraints()->find_constrained_klass(class_name, class_loader);
  2464     // Check accessibility.
  2464     // Check accessibility.
  2465     if (ss.is_object() && accessing_klass.not_null()) {
  2465     if (ss.is_object() && accessing_klass.not_null()) {
  2466       Klass* sel_klass = java_lang_Class::as_Klass(mirror);
  2466       Klass* sel_klass = java_lang_Class::as_Klass(mirror);
  2467       mirror = NULL;  // safety
  2467       mirror = NULL;  // safety
  2468       // Emulate ConstantPool::verify_constant_pool_resolve.
  2468       // Emulate ConstantPool::verify_constant_pool_resolve.
  2469       if (Klass::cast(sel_klass)->oop_is_objArray())
  2469       if (sel_klass->oop_is_objArray())
  2470         sel_klass = ObjArrayKlass::cast(sel_klass)->bottom_klass();
  2470         sel_klass = ObjArrayKlass::cast(sel_klass)->bottom_klass();
  2471       if (Klass::cast(sel_klass)->oop_is_instance()) {
  2471       if (sel_klass->oop_is_instance()) {
  2472         KlassHandle sel_kh(THREAD, sel_klass);
  2472         KlassHandle sel_kh(THREAD, sel_klass);
  2473         LinkResolver::check_klass_accessability(accessing_klass, sel_kh, CHECK_(empty));
  2473         LinkResolver::check_klass_accessability(accessing_klass, sel_kh, CHECK_(empty));
  2474       }
  2474       }
  2475     }
  2475     }
  2476   }
  2476   }