# HG changeset patch # User mbalao # Date 1579141471 0 # Node ID 1b0c1a628b3e11b7efca7e62cf359be2c6946a32 # Parent 6cfd99d2b3e943582978f894eb0f192588cc6486 8225261: Better method resolutions Reviewed-by: andrew diff -r 6cfd99d2b3e9 -r 1b0c1a628b3e src/share/vm/oops/klassVtable.cpp --- 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() : "", 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;