Tue, 08 Oct 2019 10:26:17 -0400
8225261: Better method resolutions
Reviewed-by: andrew
Contributed-by: lois.foltan@oracle.com
src/share/vm/oops/klassVtable.cpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/oops/klassVtable.cpp Mon Jan 06 06:55:50 2020 +0000 1.2 +++ b/src/share/vm/oops/klassVtable.cpp Tue Oct 08 10:26:17 2019 -0400 1.3 @@ -289,22 +289,25 @@ 1.4 int vtable_index, Handle target_loader, Symbol* target_classname, Thread * THREAD) { 1.5 InstanceKlass* superk = initialsuper; 1.6 while (superk != NULL && superk->super() != NULL) { 1.7 - InstanceKlass* supersuperklass = InstanceKlass::cast(superk->super()); 1.8 - klassVtable* ssVtable = supersuperklass->vtable(); 1.9 + klassVtable* ssVtable = (superk->super())->vtable(); 1.10 if (vtable_index < ssVtable->length()) { 1.11 Method* super_method = ssVtable->method_at(vtable_index); 1.12 + // get the class holding the matching method 1.13 + // make sure you use that class for is_override 1.14 + InstanceKlass* supermethodholder = super_method->method_holder(); 1.15 #ifndef PRODUCT 1.16 Symbol* name= target_method()->name(); 1.17 Symbol* signature = target_method()->signature(); 1.18 assert(super_method->name() == name && super_method->signature() == signature, "vtable entry name/sig mismatch"); 1.19 #endif 1.20 - if (supersuperklass->is_override(super_method, target_loader, target_classname, THREAD)) { 1.21 + 1.22 + if (supermethodholder->is_override(super_method, target_loader, target_classname, THREAD)) { 1.23 #ifndef PRODUCT 1.24 if (PrintVtables && Verbose) { 1.25 ResourceMark rm(THREAD); 1.26 char* sig = target_method()->name_and_sig_as_C_string(); 1.27 tty->print("transitive overriding superclass %s with %s::%s index %d, original flags: ", 1.28 - supersuperklass->internal_name(), 1.29 + supermethodholder->internal_name(), 1.30 _klass->internal_name(), sig, vtable_index); 1.31 super_method->access_flags().print_on(tty); 1.32 if (super_method->is_default_method()) { 1.33 @@ -656,7 +659,7 @@ 1.34 1.35 // search through the super class hierarchy to see if we need 1.36 // a new entry 1.37 - ResourceMark rm; 1.38 + ResourceMark rm(THREAD); 1.39 Symbol* name = target_method()->name(); 1.40 Symbol* signature = target_method()->signature(); 1.41 Klass* k = super;