diff options
Diffstat (limited to 'runtime/reflection-inl.h')
-rw-r--r-- | runtime/reflection-inl.h | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/runtime/reflection-inl.h b/runtime/reflection-inl.h index c4d4fae17c..68e7a10e01 100644 --- a/runtime/reflection-inl.h +++ b/runtime/reflection-inl.h @@ -29,11 +29,10 @@ namespace art { -inline bool ConvertPrimitiveValue(bool unbox_for_result, - Primitive::Type srcType, - Primitive::Type dstType, - const JValue& src, - JValue* dst) { +inline bool ConvertPrimitiveValueNoThrow(Primitive::Type srcType, + Primitive::Type dstType, + const JValue& src, + JValue* dst) { DCHECK(srcType != Primitive::kPrimNot && dstType != Primitive::kPrimNot); if (LIKELY(srcType == dstType)) { dst->SetJ(src.GetJ()); @@ -91,6 +90,18 @@ inline bool ConvertPrimitiveValue(bool unbox_for_result, default: break; } + return false; +} + +inline bool ConvertPrimitiveValue(bool unbox_for_result, + Primitive::Type srcType, + Primitive::Type dstType, + const JValue& src, + JValue* dst) { + if (ConvertPrimitiveValueNoThrow(srcType, dstType, src, dst)) { + return true; + } + if (!unbox_for_result) { ThrowIllegalArgumentException(StringPrintf("Invalid primitive conversion from %s to %s", PrettyDescriptor(srcType).c_str(), |