diff options
author | 2017-04-10 14:53:47 +0100 | |
---|---|---|
committer | 2017-07-04 11:57:13 +0100 | |
commit | 631827d9b200c93f24816c6869d72426f9fed8e3 (patch) | |
tree | 9d5d768df39e21a2678d4b9148c5ec4d1c016911 /runtime/interpreter/interpreter_common.cc | |
parent | d64fbfa3471c47d6628d6014bc4a3ac780abd26a (diff) |
Fixes for constant method handles
Add support for constant direct and interface method handles in the
DEX file.
Add error handling for field and method resolution failures in
ClassLinker::ResolveMethodHandle().
Bug: 36957105
Test: art/test/run-test --host 952-invoke-custom-kinds
Change-Id: I91a2a23ba3365310eccb8cadd193b62f57e5811c
Diffstat (limited to 'runtime/interpreter/interpreter_common.cc')
-rw-r--r-- | runtime/interpreter/interpreter_common.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc index 1b36c3f12b..b57e2b2b40 100644 --- a/runtime/interpreter/interpreter_common.cc +++ b/runtime/interpreter/interpreter_common.cc @@ -640,7 +640,7 @@ static ObjPtr<mirror::CallSite> InvokeBootstrapMethod(Thread* self, const DexFile* dex_file = referrer->GetDexFile(); const DexFile::CallSiteIdItem& csi = dex_file->GetCallSiteId(call_site_idx); - StackHandleScope<9> hs(self); + StackHandleScope<10> hs(self); Handle<mirror::ClassLoader> class_loader(hs.NewHandle(referrer->GetClassLoader())); Handle<mirror::DexCache> dex_cache(hs.NewHandle(referrer->GetDexCache())); @@ -836,9 +836,13 @@ static ObjPtr<mirror::CallSite> InvokeBootstrapMethod(Thread* self, return nullptr; } - // Check the target method type matches the method type requested. - if (UNLIKELY(!target->GetMethodType()->IsExactMatch(method_type.Get()))) { - ThrowWrongMethodTypeException(target->GetMethodType(), method_type.Get()); + // Check the target method type matches the method type requested modulo the receiver + // needs to be compatible rather than exact. + Handle<mirror::MethodType> target_method_type = hs.NewHandle(target->GetMethodType()); + if (UNLIKELY(!target_method_type->IsExactMatch(method_type.Get()) && + !IsParameterTypeConvertible(target_method_type->GetPTypes()->GetWithoutChecks(0), + method_type->GetPTypes()->GetWithoutChecks(0)))) { + ThrowWrongMethodTypeException(target_method_type.Get(), method_type.Get()); return nullptr; } |