< prev index next >
src/share/vm/classfile/systemDictionary.cpp
Print this page
rev 11945 : 8023697: failed class resolution reports different class name in detail message for the first and subsequent times
Summary: Cache detail message when we cache exception for constant pool resolution.
Reviewed-by: acorn, twisti, jrose
rev 11952 : Merge jdk8u272-b02
*** 183,198 ****
Klass* SystemDictionary::resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS) {
Klass* klass = resolve_or_null(class_name, class_loader, protection_domain, THREAD);
if (HAS_PENDING_EXCEPTION || klass == NULL) {
KlassHandle k_h(THREAD, klass);
// can return a null klass
! klass = handle_resolution_exception(class_name, class_loader, protection_domain, throw_error, k_h, THREAD);
}
return klass;
}
! Klass* SystemDictionary::handle_resolution_exception(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, KlassHandle klass_h, TRAPS) {
if (HAS_PENDING_EXCEPTION) {
// If we have a pending exception we forward it to the caller, unless throw_error is true,
// in which case we have to check whether the pending exception is a ClassNotFoundException,
// and if so convert it to a NoClassDefFoundError
// And chain the original ClassNotFoundException
--- 183,200 ----
Klass* SystemDictionary::resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS) {
Klass* klass = resolve_or_null(class_name, class_loader, protection_domain, THREAD);
if (HAS_PENDING_EXCEPTION || klass == NULL) {
KlassHandle k_h(THREAD, klass);
// can return a null klass
! klass = handle_resolution_exception(class_name, throw_error, k_h, THREAD);
}
return klass;
}
! Klass* SystemDictionary::handle_resolution_exception(Symbol* class_name,
! bool throw_error,
! KlassHandle klass_h, TRAPS) {
if (HAS_PENDING_EXCEPTION) {
// If we have a pending exception we forward it to the caller, unless throw_error is true,
// in which case we have to check whether the pending exception is a ClassNotFoundException,
// and if so convert it to a NoClassDefFoundError
// And chain the original ClassNotFoundException
*** 396,406 ****
placeholders()->find_and_remove(p_index, p_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, THREAD);
SystemDictionary_lock->notify_all();
}
if (HAS_PENDING_EXCEPTION || superk_h() == NULL) {
// can null superk
! superk_h = KlassHandle(THREAD, handle_resolution_exception(class_name, class_loader, protection_domain, true, superk_h, THREAD));
}
return superk_h();
}
--- 398,408 ----
placeholders()->find_and_remove(p_index, p_hash, child_name, loader_data, PlaceholderTable::LOAD_SUPER, THREAD);
SystemDictionary_lock->notify_all();
}
if (HAS_PENDING_EXCEPTION || superk_h() == NULL) {
// can null superk
! superk_h = KlassHandle(THREAD, handle_resolution_exception(class_name, true, superk_h, THREAD));
}
return superk_h();
}
*** 2244,2275 ****
}
}
// Add entry to resolution error table to record the error when the first
// attempt to resolve a reference to a class has failed.
! void SystemDictionary::add_resolution_error(constantPoolHandle pool, int which, Symbol* error) {
unsigned int hash = resolution_errors()->compute_hash(pool, which);
int index = resolution_errors()->hash_to_index(hash);
{
MutexLocker ml(SystemDictionary_lock, Thread::current());
! resolution_errors()->add_entry(index, hash, pool, which, error);
}
}
// Delete a resolution error for RedefineClasses for a constant pool is going away
void SystemDictionary::delete_resolution_error(ConstantPool* pool) {
resolution_errors()->delete_entry(pool);
}
// Lookup resolution error table. Returns error if found, otherwise NULL.
! Symbol* SystemDictionary::find_resolution_error(constantPoolHandle pool, int which) {
unsigned int hash = resolution_errors()->compute_hash(pool, which);
int index = resolution_errors()->hash_to_index(hash);
{
MutexLocker ml(SystemDictionary_lock, Thread::current());
ResolutionErrorEntry* entry = resolution_errors()->find_entry(index, hash, pool, which);
! return (entry != NULL) ? entry->error() : (Symbol*)NULL;
}
}
// Signature constraints ensure that callers and callees agree about
--- 2246,2284 ----
}
}
// Add entry to resolution error table to record the error when the first
// attempt to resolve a reference to a class has failed.
! void SystemDictionary::add_resolution_error(constantPoolHandle pool, int which,
! Symbol* error, Symbol* message) {
unsigned int hash = resolution_errors()->compute_hash(pool, which);
int index = resolution_errors()->hash_to_index(hash);
{
MutexLocker ml(SystemDictionary_lock, Thread::current());
! resolution_errors()->add_entry(index, hash, pool, which, error, message);
}
}
// Delete a resolution error for RedefineClasses for a constant pool is going away
void SystemDictionary::delete_resolution_error(ConstantPool* pool) {
resolution_errors()->delete_entry(pool);
}
// Lookup resolution error table. Returns error if found, otherwise NULL.
! Symbol* SystemDictionary::find_resolution_error(constantPoolHandle pool, int which,
! Symbol** message) {
unsigned int hash = resolution_errors()->compute_hash(pool, which);
int index = resolution_errors()->hash_to_index(hash);
{
MutexLocker ml(SystemDictionary_lock, Thread::current());
ResolutionErrorEntry* entry = resolution_errors()->find_entry(index, hash, pool, which);
! if (entry != NULL) {
! *message = entry->message();
! return entry->error();
! } else {
! return NULL;
! }
}
}
// Signature constraints ensure that callers and callees agree about
< prev index next >