8221992: Fix old method replacement in ResolvedMethodTable
authorcoleenp
Thu, 04 Apr 2019 17:23:05 -0400
changeset 54431 ad9fa99fa48e
parent 54430 fb25cd198a10
child 54432 532e88de77eb
8221992: Fix old method replacement in ResolvedMethodTable Summary: Use method get_new_method() which is used in other call sites. Reviewed-by: sspitsyn
src/hotspot/share/prims/resolvedMethodTable.cpp
--- a/src/hotspot/share/prims/resolvedMethodTable.cpp	Thu Apr 04 14:19:29 2019 -0700
+++ b/src/hotspot/share/prims/resolvedMethodTable.cpp	Thu Apr 04 17:23:05 2019 -0400
@@ -126,17 +126,14 @@
 
   Method* method = m();
   // Check if method has been redefined while taking out ResolvedMethodTable_lock, if so
-  // use new method.  The old method won't be deallocated because it's passed in as a Handle.
+  // use new method in the ResolvedMethodName.  The old method won't be deallocated
+  // yet because it's passed in as a Handle.
   if (method->is_old()) {
-    // Replace method with redefined version
-    InstanceKlass* holder = method->method_holder();
-    method = holder->method_with_idnum(method->method_idnum());
-    if (method == NULL) {
-      // Replace deleted method with NSME.
-      method = Universe::throw_no_such_method_error();
-    }
+    method = (method->is_deleted()) ? Universe::throw_no_such_method_error() :
+                                      method->get_new_method();
     java_lang_invoke_ResolvedMethodName::set_vmtarget(resolved_method_name(), method);
   }
+
   // Set flag in class to indicate this InstanceKlass has entries in the table
   // to avoid walking table during redefinition if none of the redefined classes
   // have any membernames in the table.