From e9dd04f633fcffc485f8d74861f39f66fc8bc522 Mon Sep 17 00:00:00 2001 From: Alex Light Date: Wed, 16 Mar 2016 16:09:45 -0700 Subject: [PATCH] Revert "Revert "Fix issue with proxy invocation on default methods"" This reverts commit daf58c80d42f024aae0cb94ebd2c0bd61ebbf240. Bug: 27621360 Change-Id: I56fccf19ae80451be4c316ba14911c667cbe9e47 --- runtime/class_linker.cc | 14 +++++++++++--- runtime/entrypoints/quick/quick_trampoline_entrypoints.cc | 6 +++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 3c69323b2..d0a784dfc 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -4265,10 +4265,18 @@ void ClassLinker::CreateProxyMethod(Handle klass, ArtMethod* prot DCHECK(out != nullptr); out->CopyFrom(prototype, image_pointer_size_); - // Set class to be the concrete proxy class and clear the abstract flag, modify exceptions to - // the intersection of throw exceptions as defined in Proxy + // Set class to be the concrete proxy class. out->SetDeclaringClass(klass.Get()); - out->SetAccessFlags((out->GetAccessFlags() & ~kAccAbstract) | kAccFinal); + // Clear the abstract, default and conflict flags to ensure that defaults aren't picked in + // preference to the invocation handler. + const uint32_t kRemoveFlags = kAccAbstract | kAccDefault | kAccDefaultConflict; + // Make the method final. + const uint32_t kAddFlags = kAccFinal; + out->SetAccessFlags((out->GetAccessFlags() & ~kRemoveFlags) | kAddFlags); + + // Clear the dex_code_item_offset_. It needs to be 0 since proxy methods have no CodeItems but the + // method they copy might (if it's a default method). + out->SetCodeItemOffset(0); // At runtime the method looks like a reference and argument saving method, clone the code // related parameters from this method. diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc index 24986253f..7005aa554 100644 --- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc +++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc @@ -653,13 +653,13 @@ extern "C" uint64_t artQuickToInterpreterBridge(ArtMethod* method, Thread* self, JValue tmp_value; ShadowFrame* deopt_frame = self->PopStackedShadowFrame( StackedShadowFrameType::kSingleFrameDeoptimizationShadowFrame, false); - const DexFile::CodeItem* code_item = method->GetCodeItem(); - DCHECK(code_item != nullptr) << PrettyMethod(method); ManagedStack fragment; DCHECK(!method->IsNative()) << PrettyMethod(method); uint32_t shorty_len = 0; - auto* non_proxy_method = method->GetInterfaceMethodIfProxy(sizeof(void*)); + ArtMethod* non_proxy_method = method->GetInterfaceMethodIfProxy(sizeof(void*)); + const DexFile::CodeItem* code_item = non_proxy_method->GetCodeItem(); + DCHECK(code_item != nullptr) << PrettyMethod(method); const char* shorty = non_proxy_method->GetShorty(&shorty_len); JValue result; -- 2.11.0