hotspot/src/share/vm/classfile/systemDictionary.cpp
changeset 24334 36096f7271f4
parent 23872 536c66fc43d3
child 24426 0a69c8cdfca9
child 24337 ddce5dcb6be1
equal deleted inserted replaced
24333:c7214442139d 24334:36096f7271f4
   170 Klass* SystemDictionary::resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS) {
   170 Klass* SystemDictionary::resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS) {
   171   Klass* klass = resolve_or_null(class_name, class_loader, protection_domain, THREAD);
   171   Klass* klass = resolve_or_null(class_name, class_loader, protection_domain, THREAD);
   172   if (HAS_PENDING_EXCEPTION || klass == NULL) {
   172   if (HAS_PENDING_EXCEPTION || klass == NULL) {
   173     KlassHandle k_h(THREAD, klass);
   173     KlassHandle k_h(THREAD, klass);
   174     // can return a null klass
   174     // can return a null klass
   175     klass = handle_resolution_exception(class_name, class_loader, protection_domain, throw_error, k_h, THREAD);
   175     klass = handle_resolution_exception(class_name, throw_error, k_h, THREAD);
   176   }
   176   }
   177   return klass;
   177   return klass;
   178 }
   178 }
   179 
   179 
   180 Klass* SystemDictionary::handle_resolution_exception(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, KlassHandle klass_h, TRAPS) {
   180 Klass* SystemDictionary::handle_resolution_exception(Symbol* class_name,
       
   181                                                      bool throw_error,
       
   182                                                      KlassHandle klass_h, TRAPS) {
   181   if (HAS_PENDING_EXCEPTION) {
   183   if (HAS_PENDING_EXCEPTION) {
   182     // If we have a pending exception we forward it to the caller, unless throw_error is true,
   184     // If we have a pending exception we forward it to the caller, unless throw_error is true,
   183     // in which case we have to check whether the pending exception is a ClassNotFoundException,
   185     // in which case we have to check whether the pending exception is a ClassNotFoundException,
   184     // and if so convert it to a NoClassDefFoundError
   186     // and if so convert it to a NoClassDefFoundError
   185     // And chain the original ClassNotFoundException
   187     // And chain the original ClassNotFoundException
   383     placeholders()->find_and_remove(p_index, p_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, THREAD);
   385     placeholders()->find_and_remove(p_index, p_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, THREAD);
   384     SystemDictionary_lock->notify_all();
   386     SystemDictionary_lock->notify_all();
   385   }
   387   }
   386   if (HAS_PENDING_EXCEPTION || superk_h() == NULL) {
   388   if (HAS_PENDING_EXCEPTION || superk_h() == NULL) {
   387     // can null superk
   389     // can null superk
   388     superk_h = KlassHandle(THREAD, handle_resolution_exception(class_name, class_loader, protection_domain, true, superk_h, THREAD));
   390     superk_h = KlassHandle(THREAD, handle_resolution_exception(class_name, true, superk_h, THREAD));
   389   }
   391   }
   390 
   392 
   391   return superk_h();
   393   return superk_h();
   392 }
   394 }
   393 
   395 
  2117   }
  2119   }
  2118 }
  2120 }
  2119 
  2121 
  2120 // Add entry to resolution error table to record the error when the first
  2122 // Add entry to resolution error table to record the error when the first
  2121 // attempt to resolve a reference to a class has failed.
  2123 // attempt to resolve a reference to a class has failed.
  2122 void SystemDictionary::add_resolution_error(constantPoolHandle pool, int which, Symbol* error) {
  2124 void SystemDictionary::add_resolution_error(constantPoolHandle pool, int which,
       
  2125                                             Symbol* error, Symbol* message) {
  2123   unsigned int hash = resolution_errors()->compute_hash(pool, which);
  2126   unsigned int hash = resolution_errors()->compute_hash(pool, which);
  2124   int index = resolution_errors()->hash_to_index(hash);
  2127   int index = resolution_errors()->hash_to_index(hash);
  2125   {
  2128   {
  2126     MutexLocker ml(SystemDictionary_lock, Thread::current());
  2129     MutexLocker ml(SystemDictionary_lock, Thread::current());
  2127     resolution_errors()->add_entry(index, hash, pool, which, error);
  2130     resolution_errors()->add_entry(index, hash, pool, which, error, message);
  2128   }
  2131   }
  2129 }
  2132 }
  2130 
  2133 
  2131 // Delete a resolution error for RedefineClasses for a constant pool is going away
  2134 // Delete a resolution error for RedefineClasses for a constant pool is going away
  2132 void SystemDictionary::delete_resolution_error(ConstantPool* pool) {
  2135 void SystemDictionary::delete_resolution_error(ConstantPool* pool) {
  2133   resolution_errors()->delete_entry(pool);
  2136   resolution_errors()->delete_entry(pool);
  2134 }
  2137 }
  2135 
  2138 
  2136 // Lookup resolution error table. Returns error if found, otherwise NULL.
  2139 // Lookup resolution error table. Returns error if found, otherwise NULL.
  2137 Symbol* SystemDictionary::find_resolution_error(constantPoolHandle pool, int which) {
  2140 Symbol* SystemDictionary::find_resolution_error(constantPoolHandle pool, int which,
       
  2141                                                 Symbol** message) {
  2138   unsigned int hash = resolution_errors()->compute_hash(pool, which);
  2142   unsigned int hash = resolution_errors()->compute_hash(pool, which);
  2139   int index = resolution_errors()->hash_to_index(hash);
  2143   int index = resolution_errors()->hash_to_index(hash);
  2140   {
  2144   {
  2141     MutexLocker ml(SystemDictionary_lock, Thread::current());
  2145     MutexLocker ml(SystemDictionary_lock, Thread::current());
  2142     ResolutionErrorEntry* entry = resolution_errors()->find_entry(index, hash, pool, which);
  2146     ResolutionErrorEntry* entry = resolution_errors()->find_entry(index, hash, pool, which);
  2143     return (entry != NULL) ? entry->error() : (Symbol*)NULL;
  2147     if (entry != NULL) {
       
  2148       *message = entry->message();
       
  2149       return entry->error();
       
  2150     } else {
       
  2151       return NULL;
       
  2152     }
  2144   }
  2153   }
  2145 }
  2154 }
  2146 
  2155 
  2147 
  2156 
  2148 // Signature constraints ensure that callers and callees agree about
  2157 // Signature constraints ensure that callers and callees agree about