Don't trust all the bits in a JValue when boxing.
Callers can't be trusted to have zeroed the bits unused bits in the JValue;
we could chase them all down and fix them, but it's probably safer to go back
to the old paranoia.
Change-Id: Ic3967d5f58fc69b7dbbe00a8ea56baf6457631ee
diff --git a/src/reflection.cc b/src/reflection.cc
index 993a939..c06a879 100644
--- a/src/reflection.cc
+++ b/src/reflection.cc
@@ -235,30 +235,40 @@
}
Method* m = NULL;
+ JValue args[1];
+ args[0].j = 0;
switch (src_class) {
case Primitive::kPrimBoolean:
m = gBoolean_valueOf;
+ args[0].z = value.z;
break;
case Primitive::kPrimByte:
m = gByte_valueOf;
+ args[0].b = value.b;
break;
case Primitive::kPrimChar:
m = gCharacter_valueOf;
+ args[0].c = value.c;
break;
case Primitive::kPrimDouble:
m = gDouble_valueOf;
+ args[0].d = value.d;
break;
case Primitive::kPrimFloat:
m = gFloat_valueOf;
+ args[0].f = value.f;
break;
case Primitive::kPrimInt:
m = gInteger_valueOf;
+ args[0].i = value.i;
break;
case Primitive::kPrimLong:
m = gLong_valueOf;
+ args[0].j = value.j;
break;
case Primitive::kPrimShort:
m = gShort_valueOf;
+ args[0].s = value.s;
break;
case Primitive::kPrimVoid:
// There's no such thing as a void field, and void methods invoked via reflection return null.
@@ -270,7 +280,6 @@
Thread* self = Thread::Current();
ScopedThreadStateChange tsc(self, Thread::kRunnable);
- JValue args[1] = { value };
m->Invoke(self, NULL, args, &value);
}