ART: Fix OOME case in proxy dispatch
Even just creating the java.lang.reflect.Method to pass to the
handler may throw an exception.
Add coverage to run-test 044.
Bug: 68817306
Test: m test-art-host
Change-Id: Iacf8fd679b9e8a81ff7bf7d5f6227e875ab10518
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index 4d7c2a1..a4a8c34 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -961,9 +961,13 @@
self->EndAssertNoThreadSuspension(old_cause);
DCHECK_EQ(Runtime::Current()->GetClassLinker()->GetImagePointerSize(), kRuntimePointerSize);
DCHECK(!Runtime::Current()->IsActiveTransaction());
- jobject interface_method_jobj = soa.AddLocalReference<jobject>(
- mirror::Method::CreateFromArtMethod<kRuntimePointerSize, false>(soa.Self(),
- interface_method));
+ ObjPtr<mirror::Method> interface_reflect_method =
+ mirror::Method::CreateFromArtMethod<kRuntimePointerSize, false>(soa.Self(), interface_method);
+ if (interface_reflect_method == nullptr) {
+ soa.Self()->AssertPendingOOMException();
+ return 0;
+ }
+ jobject interface_method_jobj = soa.AddLocalReference<jobject>(interface_reflect_method);
// All naked Object*s should now be in jobjects, so its safe to go into the main invoke code
// that performs allocations.