diff options
author | 2016-01-26 16:07:41 -0800 | |
---|---|---|
committer | 2016-01-27 13:47:38 -0800 | |
commit | 12771081679e43a6c34cd35c80ff9663bbdd15e9 (patch) | |
tree | 1c552b2a53a8598ec7870a42dfb095fb58c646a6 /runtime/class_linker.cc | |
parent | 2aaf58e90c9229610b2a16644e9866b6741ce9ca (diff) |
Fix issue with IMT dispatch.
If a default and an abstract method map to the same IMT slot one could
end up invoking the default method when one invokes the abstract
method.
Bug: 24618811
Bug: 26827549
Change-Id: I2ccb8e8b5362eb4961531b63e7b946ad8ef936a6
Diffstat (limited to 'runtime/class_linker.cc')
-rw-r--r-- | runtime/class_linker.cc | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index bb709e8774..080cfb4e47 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -6245,15 +6245,7 @@ bool ClassLinker::LinkInterfaceMethods( } // case kAbstractFound } if (LIKELY(fill_tables)) { - if (current_method != nullptr) { - // We found a default method implementation. Record it in the iftable and IMT. - method_array->SetElementPtrSize(j, current_method, image_pointer_size_); - SetIMTRef(unimplemented_method, - imt_conflict_method, - image_pointer_size_, - current_method, - /*out*/imt_ptr); - } else if (!super_interface) { + if (current_method == nullptr && !super_interface) { // We could not find an implementation for this method and since it is a brand new // interface we searched the entire vtable (and all default methods) for an // implementation but couldn't find one. We therefore need to make a miranda method. @@ -6269,7 +6261,17 @@ bool ClassLinker::LinkInterfaceMethods( new(miranda_method) ArtMethod(interface_method, image_pointer_size_); miranda_methods.push_back(miranda_method); } - method_array->SetElementPtrSize(j, miranda_method, image_pointer_size_); + current_method = miranda_method; + } + + if (current_method != nullptr) { + // We found a default method implementation. Record it in the iftable and IMT. + method_array->SetElementPtrSize(j, current_method, image_pointer_size_); + SetIMTRef(unimplemented_method, + imt_conflict_method, + image_pointer_size_, + current_method, + /*out*/imt_ptr); } } } // For each method in interface end. |