From e2ca0d43b52329cfe1e5b6d1aa9a15618ae9a549 Mon Sep 17 00:00:00 2001 From: Caleb Fenton Date: Mon, 15 Feb 2016 09:58:20 -0800 Subject: [PATCH] Guess better as to when to coax 0 to null --- smalivm/src/main/java/org/cf/smalivm/MethodReflector.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/smalivm/src/main/java/org/cf/smalivm/MethodReflector.java b/smalivm/src/main/java/org/cf/smalivm/MethodReflector.java index a3b19edd5..8d10477c7 100644 --- a/smalivm/src/main/java/org/cf/smalivm/MethodReflector.java +++ b/smalivm/src/main/java/org/cf/smalivm/MethodReflector.java @@ -129,8 +129,10 @@ private InvocationArguments getArguments(MethodState mState) throws ClassNotFoun if (argItem.isPrimitiveOrWrapper()) { arg = Utils.castToPrimitive(arg, parameterTypeName); } else { - if (arg instanceof Number && argItem.getIntegerValue() == 0) { - // Passing 0 as a non-primitive type means it's null (thanks Dalvik) + if (arg instanceof Number && argItem.getIntegerValue() == 0 && !parameterTypeName + .equals("Ljava/lang/Object;")) { + // TODO: medium - how the hell does Dalvik really know if it's a null or a 0? + // Passing 0 as a non-primitive type *COULD* it's null (thanks Dalvik) arg = null; } }