# HG changeset patch # User never # Date 1296524901 28800 # Node ID 057b1c20fd7e2f0830a2b65b4f8feb1bad84975d # Parent 96d498ec7ae11d97ce08e34333f6a7ca553b0876 6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111" Reviewed-by: jrose, acorn diff -r 96d498ec7ae1 -r 057b1c20fd7e hotspot/src/share/vm/ci/ciEnv.cpp --- a/hotspot/src/share/vm/ci/ciEnv.cpp Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/share/vm/ci/ciEnv.cpp Mon Jan 31 17:48:21 2011 -0800 @@ -412,13 +412,16 @@ fail_type = _unloaded_ciinstance_klass; } KlassHandle found_klass; - if (!require_local) { - klassOop kls = SystemDictionary::find_constrained_instance_or_array_klass( - sym, loader, KILL_COMPILE_ON_FATAL_(fail_type)); - found_klass = KlassHandle(THREAD, kls); - } else { - klassOop kls = SystemDictionary::find_instance_or_array_klass( - sym, loader, domain, KILL_COMPILE_ON_FATAL_(fail_type)); + { + MutexLocker ml(Compile_lock); + klassOop kls; + if (!require_local) { + kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, + KILL_COMPILE_ON_FATAL_(fail_type)); + } else { + kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, + KILL_COMPILE_ON_FATAL_(fail_type)); + } found_klass = KlassHandle(THREAD, kls); } diff -r 96d498ec7ae1 -r 057b1c20fd7e hotspot/src/share/vm/ci/ciInstanceKlass.cpp --- a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp Mon Jan 31 17:48:21 2011 -0800 @@ -46,6 +46,7 @@ ciKlass(h_k), _non_static_fields(NULL) { assert(get_Klass()->oop_is_instance(), "wrong type"); + assert(get_instanceKlass()->is_loaded(), "must be at least loaded"); instanceKlass* ik = get_instanceKlass(); AccessFlags access_flags = ik->access_flags(); diff -r 96d498ec7ae1 -r 057b1c20fd7e hotspot/src/share/vm/classfile/loaderConstraints.cpp --- a/hotspot/src/share/vm/classfile/loaderConstraints.cpp Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/share/vm/classfile/loaderConstraints.cpp Mon Jan 31 17:48:21 2011 -0800 @@ -322,8 +322,14 @@ klassOop LoaderConstraintTable::find_constrained_klass(Symbol* name, Handle loader) { LoaderConstraintEntry *p = *(find_loader_constraint(name, loader)); - if (p != NULL && p->klass() != NULL) + if (p != NULL && p->klass() != NULL) { + if (Klass::cast(p->klass())->oop_is_instance() && !instanceKlass::cast(p->klass())->is_loaded()) { + // Only return fully loaded classes. Classes found through the + // constraints might still be in the process of loading. + return NULL; + } return p->klass(); + } // No constraints, or else no klass loaded yet. return NULL; diff -r 96d498ec7ae1 -r 057b1c20fd7e hotspot/src/share/vm/classfile/systemDictionary.cpp --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp Thu Jan 27 16:11:27 2011 -0800 +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp Mon Jan 31 17:48:21 2011 -0800 @@ -1690,6 +1690,8 @@ void SystemDictionary::add_to_hierarchy(instanceKlassHandle k, TRAPS) { assert(k.not_null(), "just checking"); + assert_locked_or_safepoint(Compile_lock); + // Link into hierachy. Make sure the vtables are initialized before linking into k->append_to_sibling_list(); // add to superklass/sibling list k->process_interfaces(THREAD); // handle all "implements" declarations @@ -2152,6 +2154,9 @@ } +// Try to find a class name using the loader constraints. The +// loader constraints might know about a class that isn't fully loaded +// yet and these will be ignored. klassOop SystemDictionary::find_constrained_instance_or_array_klass( Symbol* class_name, Handle class_loader, TRAPS) {