219 if (throw_error) { 220 THROW_MSG_NULL(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string()); 221 } else { 222 THROW_MSG_NULL(vmSymbols::java_lang_ClassNotFoundException(), class_name->as_C_string()); 223 } 224 } 225 return klass; 226 } 227 228 229 Klass* SystemDictionary::resolve_or_fail(Symbol* class_name, 230 bool throw_error, TRAPS) 231 { 232 return resolve_or_fail(class_name, Handle(), Handle(), throw_error, THREAD); 233 } 234 235 236 // Forwards to resolve_instance_class_or_null 237 238 Klass* SystemDictionary::resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS) { 239 assert(THREAD->can_call_java(), 240 "can not load classes with compiler thread: class=%s, classloader=%s", 241 class_name->as_C_string(), 242 class_loader.is_null() ? "null" : class_loader->klass()->name()->as_C_string()); 243 if (FieldType::is_array(class_name)) { 244 return resolve_array_class_or_null(class_name, class_loader, protection_domain, THREAD); 245 } else if (FieldType::is_obj(class_name)) { 246 ResourceMark rm(THREAD); 247 // Ignore wrapping L and ;. 248 TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1, 249 class_name->utf8_length() - 2, CHECK_NULL); 250 return resolve_instance_class_or_null(name, class_loader, protection_domain, THREAD); 251 } else { 252 return resolve_instance_class_or_null(class_name, class_loader, protection_domain, THREAD); 253 } 254 } 255 256 Klass* SystemDictionary::resolve_or_null(Symbol* class_name, TRAPS) { 257 return resolve_or_null(class_name, Handle(), Handle(), THREAD); 258 } 259 260 // Forwards to resolve_instance_class_or_null 261 262 Klass* SystemDictionary::resolve_array_class_or_null(Symbol* class_name, 691 DoObjectLock = false; 692 } 693 694 unsigned int p_hash = placeholders()->compute_hash(name, loader_data); 695 int p_index = placeholders()->hash_to_index(p_hash); 696 697 // Class is not in SystemDictionary so we have to do loading. 698 // Make sure we are synchronized on the class loader before we proceed 699 Handle lockObject = compute_loader_lock_object(class_loader, THREAD); 700 check_loader_lock_contention(lockObject, THREAD); 701 ObjectLocker ol(lockObject, THREAD, DoObjectLock); 702 703 // Check again (after locking) if class already exist in SystemDictionary 704 bool class_has_been_loaded = false; 705 bool super_load_in_progress = false; 706 bool havesupername = false; 707 InstanceKlass* k = NULL; 708 PlaceholderEntry* placeholder; 709 Symbol* superclassname = NULL; 710 711 { 712 MutexLocker mu(SystemDictionary_lock, THREAD); 713 InstanceKlass* check = find_class(d_index, d_hash, name, loader_data); 714 if (check != NULL) { 715 // Klass is already loaded, so just return it 716 class_has_been_loaded = true; 717 k = check; 718 } else { 719 placeholder = placeholders()->get_entry(p_index, p_hash, name, loader_data); 720 if (placeholder && placeholder->super_load_in_progress()) { 721 super_load_in_progress = true; 722 if (placeholder->havesupername() == true) { 723 superclassname = placeholder->supername(); 724 havesupername = true; 725 } 726 } 727 } 728 } 729 730 // If the class is in the placeholder table, class loading is in progress | 219 if (throw_error) { 220 THROW_MSG_NULL(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string()); 221 } else { 222 THROW_MSG_NULL(vmSymbols::java_lang_ClassNotFoundException(), class_name->as_C_string()); 223 } 224 } 225 return klass; 226 } 227 228 229 Klass* SystemDictionary::resolve_or_fail(Symbol* class_name, 230 bool throw_error, TRAPS) 231 { 232 return resolve_or_fail(class_name, Handle(), Handle(), throw_error, THREAD); 233 } 234 235 236 // Forwards to resolve_instance_class_or_null 237 238 Klass* SystemDictionary::resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS) { 239 if (FieldType::is_array(class_name)) { 240 return resolve_array_class_or_null(class_name, class_loader, protection_domain, THREAD); 241 } else if (FieldType::is_obj(class_name)) { 242 ResourceMark rm(THREAD); 243 // Ignore wrapping L and ;. 244 TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1, 245 class_name->utf8_length() - 2, CHECK_NULL); 246 return resolve_instance_class_or_null(name, class_loader, protection_domain, THREAD); 247 } else { 248 return resolve_instance_class_or_null(class_name, class_loader, protection_domain, THREAD); 249 } 250 } 251 252 Klass* SystemDictionary::resolve_or_null(Symbol* class_name, TRAPS) { 253 return resolve_or_null(class_name, Handle(), Handle(), THREAD); 254 } 255 256 // Forwards to resolve_instance_class_or_null 257 258 Klass* SystemDictionary::resolve_array_class_or_null(Symbol* class_name, 687 DoObjectLock = false; 688 } 689 690 unsigned int p_hash = placeholders()->compute_hash(name, loader_data); 691 int p_index = placeholders()->hash_to_index(p_hash); 692 693 // Class is not in SystemDictionary so we have to do loading. 694 // Make sure we are synchronized on the class loader before we proceed 695 Handle lockObject = compute_loader_lock_object(class_loader, THREAD); 696 check_loader_lock_contention(lockObject, THREAD); 697 ObjectLocker ol(lockObject, THREAD, DoObjectLock); 698 699 // Check again (after locking) if class already exist in SystemDictionary 700 bool class_has_been_loaded = false; 701 bool super_load_in_progress = false; 702 bool havesupername = false; 703 InstanceKlass* k = NULL; 704 PlaceholderEntry* placeholder; 705 Symbol* superclassname = NULL; 706 707 assert(THREAD->can_call_java(), 708 "can not load classes with compiler thread: class=%s, classloader=%s", 709 name->as_C_string(), 710 class_loader.is_null() ? "null" : class_loader->klass()->name()->as_C_string()); 711 { 712 MutexLocker mu(SystemDictionary_lock, THREAD); 713 InstanceKlass* check = find_class(d_index, d_hash, name, loader_data); 714 if (check != NULL) { 715 // Klass is already loaded, so just return it 716 class_has_been_loaded = true; 717 k = check; 718 } else { 719 placeholder = placeholders()->get_entry(p_index, p_hash, name, loader_data); 720 if (placeholder && placeholder->super_load_in_progress()) { 721 super_load_in_progress = true; 722 if (placeholder->havesupername() == true) { 723 superclassname = placeholder->supername(); 724 havesupername = true; 725 } 726 } 727 } 728 } 729 730 // If the class is in the placeholder table, class loading is in progress |