1.1 --- a/src/share/vm/oops/instanceKlass.cpp Thu Nov 20 11:06:26 2014 +0100 1.2 +++ b/src/share/vm/oops/instanceKlass.cpp Wed Nov 19 13:02:11 2014 -0500 1.3 @@ -2947,28 +2947,27 @@ 1.4 return NULL; 1.5 } 1.6 1.7 -void InstanceKlass::add_member_name(int index, Handle mem_name) { 1.8 +bool InstanceKlass::add_member_name(Handle mem_name) { 1.9 jweak mem_name_wref = JNIHandles::make_weak_global(mem_name); 1.10 MutexLocker ml(MemberNameTable_lock); 1.11 - assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds"); 1.12 DEBUG_ONLY(No_Safepoint_Verifier nsv); 1.13 1.14 + // Check if method has been redefined while taking out MemberNameTable_lock, if so 1.15 + // return false. We cannot cache obsolete methods. They will crash when the function 1.16 + // is called! 1.17 + Method* method = (Method*)java_lang_invoke_MemberName::vmtarget(mem_name()); 1.18 + if (method->is_obsolete()) { 1.19 + return false; 1.20 + } else if (method->is_old()) { 1.21 + // Replace method with redefined version 1.22 + java_lang_invoke_MemberName::set_vmtarget(mem_name(), method_with_idnum(method->method_idnum())); 1.23 + } 1.24 + 1.25 if (_member_names == NULL) { 1.26 _member_names = new (ResourceObj::C_HEAP, mtClass) MemberNameTable(idnum_allocated_count()); 1.27 } 1.28 - _member_names->add_member_name(index, mem_name_wref); 1.29 -} 1.30 - 1.31 -oop InstanceKlass::get_member_name(int index) { 1.32 - MutexLocker ml(MemberNameTable_lock); 1.33 - assert(0 <= index && index < idnum_allocated_count(), "index is out of bounds"); 1.34 - DEBUG_ONLY(No_Safepoint_Verifier nsv); 1.35 - 1.36 - if (_member_names == NULL) { 1.37 - return NULL; 1.38 - } 1.39 - oop mem_name =_member_names->get_member_name(index); 1.40 - return mem_name; 1.41 + _member_names->add_member_name(mem_name_wref); 1.42 + return true; 1.43 } 1.44 1.45 // -----------------------------------------------------------------------------------------------------