summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Igor Murashkin <iam@google.com> 2017-02-27 22:02:14 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2017-02-27 22:02:15 +0000
commit977c5104711c8730a22b17424e64de43d9c7ebdd (patch)
tree06fc6bff813bdb82d6842dd2595c6d6d91ae646d
parent12664625ccbf7b11b7b8f8daca5ac1cb405ef7a3 (diff)
parent9d3d7524c01dd479b4e7eab9bdcb739254e60427 (diff)
Merge "proxy: Fix crash when creating proxies with dx-built libcore."
-rw-r--r--runtime/class_linker.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 9b0ffaf031..2788656735 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -4428,9 +4428,15 @@ void ClassLinker::CreateProxyConstructor(Handle<mirror::Class> klass, ArtMethod*
// Create constructor for Proxy that must initialize the method.
CHECK_EQ(GetClassRoot(kJavaLangReflectProxy)->NumDirectMethods(), 23u);
- ArtMethod* proxy_constructor = GetClassRoot(kJavaLangReflectProxy)->GetDirectMethodUnchecked(
- 8, image_pointer_size_);
- DCHECK_EQ(std::string(proxy_constructor->GetName()), "<init>");
+ // Find the <init>(InvocationHandler)V method. The exact method offset varies depending
+ // on which front-end compiler was used to build the libcore DEX files.
+ ArtMethod* proxy_constructor = GetClassRoot(kJavaLangReflectProxy)->
+ FindDeclaredDirectMethod("<init>",
+ "(Ljava/lang/reflect/InvocationHandler;)V",
+ image_pointer_size_);
+ DCHECK(proxy_constructor != nullptr)
+ << "Could not find <init> method in java.lang.reflect.Proxy";
+
// Ensure constructor is in dex cache so that we can use the dex cache to look up the overridden
// constructor method.
GetClassRoot(kJavaLangReflectProxy)->GetDexCache()->SetResolvedMethod(