< prev index next >

src/hotspot/share/classfile/systemDictionary.cpp

Print this page
rev 50604 : imported patch jep181-rev1


 228     if (throw_error) {
 229       THROW_MSG_NULL(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string());
 230     } else {
 231       THROW_MSG_NULL(vmSymbols::java_lang_ClassNotFoundException(), class_name->as_C_string());
 232     }
 233   }
 234   return klass;
 235 }
 236 
 237 
 238 Klass* SystemDictionary::resolve_or_fail(Symbol* class_name,
 239                                            bool throw_error, TRAPS)
 240 {
 241   return resolve_or_fail(class_name, Handle(), Handle(), throw_error, THREAD);
 242 }
 243 
 244 
 245 // Forwards to resolve_instance_class_or_null
 246 
 247 Klass* SystemDictionary::resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS) {
 248   assert(THREAD->can_call_java(),
 249          "can not load classes with compiler thread: class=%s, classloader=%s",
 250          class_name->as_C_string(),
 251          class_loader.is_null() ? "null" : class_loader->klass()->name()->as_C_string());
 252   if (FieldType::is_array(class_name)) {
 253     return resolve_array_class_or_null(class_name, class_loader, protection_domain, THREAD);
 254   } else if (FieldType::is_obj(class_name)) {
 255     ResourceMark rm(THREAD);
 256     // Ignore wrapping L and ;.
 257     TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1,
 258                                    class_name->utf8_length() - 2, CHECK_NULL);
 259     return resolve_instance_class_or_null(name, class_loader, protection_domain, THREAD);
 260   } else {
 261     return resolve_instance_class_or_null(class_name, class_loader, protection_domain, THREAD);
 262   }
 263 }
 264 
 265 Klass* SystemDictionary::resolve_or_null(Symbol* class_name, TRAPS) {
 266   return resolve_or_null(class_name, Handle(), Handle(), THREAD);
 267 }
 268 
 269 // Forwards to resolve_instance_class_or_null
 270 
 271 Klass* SystemDictionary::resolve_array_class_or_null(Symbol* class_name,


 675     DoObjectLock = false;
 676   }
 677 
 678   unsigned int p_hash = placeholders()->compute_hash(name);
 679   int p_index = placeholders()->hash_to_index(p_hash);
 680 
 681   // Class is not in SystemDictionary so we have to do loading.
 682   // Make sure we are synchronized on the class loader before we proceed
 683   Handle lockObject = compute_loader_lock_object(class_loader, THREAD);
 684   check_loader_lock_contention(lockObject, THREAD);
 685   ObjectLocker ol(lockObject, THREAD, DoObjectLock);
 686 
 687   // Check again (after locking) if class already exist in SystemDictionary
 688   bool class_has_been_loaded   = false;
 689   bool super_load_in_progress  = false;
 690   bool havesupername = false;
 691   InstanceKlass* k = NULL;
 692   PlaceholderEntry* placeholder;
 693   Symbol* superclassname = NULL;
 694 




 695   {
 696     MutexLocker mu(SystemDictionary_lock, THREAD);
 697     InstanceKlass* check = find_class(d_hash, name, dictionary);
 698     if (check != NULL) {
 699       // Klass is already loaded, so just return it
 700       class_has_been_loaded = true;
 701       k = check;
 702     } else {
 703       placeholder = placeholders()->get_entry(p_index, p_hash, name, loader_data);
 704       if (placeholder && placeholder->super_load_in_progress()) {
 705          super_load_in_progress = true;
 706          if (placeholder->havesupername() == true) {
 707            superclassname = placeholder->supername();
 708            havesupername = true;
 709          }
 710       }
 711     }
 712   }
 713 
 714   // If the class is in the placeholder table, class loading is in progress




 228     if (throw_error) {
 229       THROW_MSG_NULL(vmSymbols::java_lang_NoClassDefFoundError(), class_name->as_C_string());
 230     } else {
 231       THROW_MSG_NULL(vmSymbols::java_lang_ClassNotFoundException(), class_name->as_C_string());
 232     }
 233   }
 234   return klass;
 235 }
 236 
 237 
 238 Klass* SystemDictionary::resolve_or_fail(Symbol* class_name,
 239                                            bool throw_error, TRAPS)
 240 {
 241   return resolve_or_fail(class_name, Handle(), Handle(), throw_error, THREAD);
 242 }
 243 
 244 
 245 // Forwards to resolve_instance_class_or_null
 246 
 247 Klass* SystemDictionary::resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS) {




 248   if (FieldType::is_array(class_name)) {
 249     return resolve_array_class_or_null(class_name, class_loader, protection_domain, THREAD);
 250   } else if (FieldType::is_obj(class_name)) {
 251     ResourceMark rm(THREAD);
 252     // Ignore wrapping L and ;.
 253     TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1,
 254                                    class_name->utf8_length() - 2, CHECK_NULL);
 255     return resolve_instance_class_or_null(name, class_loader, protection_domain, THREAD);
 256   } else {
 257     return resolve_instance_class_or_null(class_name, class_loader, protection_domain, THREAD);
 258   }
 259 }
 260 
 261 Klass* SystemDictionary::resolve_or_null(Symbol* class_name, TRAPS) {
 262   return resolve_or_null(class_name, Handle(), Handle(), THREAD);
 263 }
 264 
 265 // Forwards to resolve_instance_class_or_null
 266 
 267 Klass* SystemDictionary::resolve_array_class_or_null(Symbol* class_name,


 671     DoObjectLock = false;
 672   }
 673 
 674   unsigned int p_hash = placeholders()->compute_hash(name);
 675   int p_index = placeholders()->hash_to_index(p_hash);
 676 
 677   // Class is not in SystemDictionary so we have to do loading.
 678   // Make sure we are synchronized on the class loader before we proceed
 679   Handle lockObject = compute_loader_lock_object(class_loader, THREAD);
 680   check_loader_lock_contention(lockObject, THREAD);
 681   ObjectLocker ol(lockObject, THREAD, DoObjectLock);
 682 
 683   // Check again (after locking) if class already exist in SystemDictionary
 684   bool class_has_been_loaded   = false;
 685   bool super_load_in_progress  = false;
 686   bool havesupername = false;
 687   InstanceKlass* k = NULL;
 688   PlaceholderEntry* placeholder;
 689   Symbol* superclassname = NULL;
 690 
 691   assert(THREAD->can_call_java(),
 692          "can not load classes with compiler thread: class=%s, classloader=%s",
 693          name->as_C_string(),
 694          class_loader.is_null() ? "null" : class_loader->klass()->name()->as_C_string());
 695   {
 696     MutexLocker mu(SystemDictionary_lock, THREAD);
 697     InstanceKlass* check = find_class(d_hash, name, dictionary);
 698     if (check != NULL) {
 699       // Klass is already loaded, so just return it
 700       class_has_been_loaded = true;
 701       k = check;
 702     } else {
 703       placeholder = placeholders()->get_entry(p_index, p_hash, name, loader_data);
 704       if (placeholder && placeholder->super_load_in_progress()) {
 705          super_load_in_progress = true;
 706          if (placeholder->havesupername() == true) {
 707            superclassname = placeholder->supername();
 708            havesupername = true;
 709          }
 710       }
 711     }
 712   }
 713 
 714   // If the class is in the placeholder table, class loading is in progress


< prev index next >