Skip to content

Commit

Permalink
Guess better as to when to coax 0 to null
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebFenton committed Feb 15, 2016
1 parent f1f3913 commit e2ca0d4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions smalivm/src/main/java/org/cf/smalivm/MethodReflector.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit e2ca0d4

Please sign in to comment.