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