Address review comments from change 000e1885701c8f.
Style fixes, and better OOM handling.
bug: 30550796
Test: make test-art-host
Change-Id: I2ab58e25bd08daace6609ba45d860994a354280f
diff --git a/runtime/method_handles-inl.h b/runtime/method_handles-inl.h
index ff5d2a1..b279a37 100644
--- a/runtime/method_handles-inl.h
+++ b/runtime/method_handles-inl.h
@@ -64,7 +64,6 @@
}
}
-REQUIRES_SHARED(Locks::mutator_lock_)
inline bool ConvertJValue(Handle<mirror::Class> from,
Handle<mirror::Class> to,
const JValue& from_value,
@@ -103,15 +102,21 @@
// First perform a primitive conversion to the unboxed equivalent of the target,
// if necessary. This should be for the rarer cases like (int->Long) etc.
if (UNLIKELY(from_type != type)) {
- if (!ConvertPrimitiveValue(false, from_type, type, from_value, to_value)) {
- return false;
- }
+ if (!ConvertPrimitiveValue(false, from_type, type, from_value, to_value)) {
+ return false;
+ }
} else {
*to_value = from_value;
}
- // Then perform the actual boxing, and then set the reference.
+ // Then perform the actual boxing, and then set the reference. Note that
+ // BoxPrimitive can return null if an OOM occurs.
ObjPtr<mirror::Object> boxed = BoxPrimitive(type, from_value);
+ if (boxed.Ptr() == nullptr) {
+ DCHECK(Thread::Current()->IsExceptionPending());
+ return false;
+ }
+
to_value->SetL(boxed.Ptr());
return true;
} else {
@@ -156,8 +161,6 @@
} else {
setter->Set(getter->Get());
}
-
- continue;
} else {
JValue from_value;
JValue to_value;