changeset 5866:1b0c1a628b3e

8225261: Better method resolutions Reviewed-by: andrew
author mbalao
date Thu, 16 Jan 2020 02:24:31 +0000
parents 6cfd99d2b3e9
children 2ab077a70b79
files src/share/vm/oops/klassVtable.cpp
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/oops/klassVtable.cpp	Mon Jan 13 20:51:28 2020 +0000
+++ b/src/share/vm/oops/klassVtable.cpp	Thu Jan 16 02:24:31 2020 +0000
@@ -224,21 +224,24 @@
                             int vtable_index, Handle target_loader, Symbol* target_classname, Thread * THREAD) {
   instanceKlass* superk = initialsuper;
   while (superk != NULL && superk->super() != NULL) {
-    instanceKlass* supersuperklass = instanceKlass::cast(superk->super());
-    klassVtable* ssVtable = supersuperklass->vtable();
+    klassVtable* ssVtable = instanceKlass::cast((superk->super()))->vtable();
     if (vtable_index < ssVtable->length()) {
       methodOop super_method = ssVtable->method_at(vtable_index);
+      // get the class holding the matching method
+      // make sure you use that class for is_override
+      instanceKlass* supermethodholder = instanceKlass::cast(super_method->method_holder());
 #ifndef PRODUCT
       Symbol* name= target_method()->name();
       Symbol* signature = target_method()->signature();
       assert(super_method->name() == name && super_method->signature() == signature, "vtable entry name/sig mismatch");
 #endif
-      if (supersuperklass->is_override(super_method, target_loader, target_classname, THREAD)) {
+
+      if (supermethodholder->is_override(super_method, target_loader, target_classname, THREAD)) {
 #ifndef PRODUCT
         if (PrintVtables && Verbose) {
           ResourceMark rm(THREAD);
           tty->print("transitive overriding superclass %s with %s::%s index %d, original flags: ",
-           supersuperklass->internal_name(),
+           supermethodholder->internal_name(),
            _klass->internal_name(), (target_method() != NULL) ?
            target_method()->name()->as_C_string() : "<NULL>", vtable_index);
            super_method->access_flags().print_on(tty);
@@ -456,7 +459,7 @@
 
   // search through the super class hierarchy to see if we need
   // a new entry
-  ResourceMark rm;
+  ResourceMark rm(THREAD);
   Symbol* name = target_method()->name();
   Symbol* signature = target_method()->signature();
   klassOop k = super;