Fix exception throwing to support no detail message.
(The empty string as a detail message is distinct from a NULL detail message,
and is treated differently by Throwable.printStackTrace.)
Change-Id: I8c65deac9f18c5782dcf6e72e4c37e6dd4174fe9
diff --git a/src/reflection.cc b/src/reflection.cc
index c560053..1294c08 100644
--- a/src/reflection.cc
+++ b/src/reflection.cc
@@ -77,7 +77,7 @@
ObjectArray<Class>* classes = Decode<ObjectArray<Class>*>(env, javaParams);
int32_t arg_count = (objects != NULL) ? objects->GetLength() : 0;
if (arg_count != classes->GetLength()) {
- self->ThrowNewException("Ljava/lang/IllegalArgumentException;",
+ self->ThrowNewExceptionF("Ljava/lang/IllegalArgumentException;",
"wrong number of arguments; expected %d, got %d",
classes->GetLength(), arg_count);
return NULL;
@@ -219,7 +219,7 @@
default:
break;
}
- Thread::Current()->ThrowNewException("Ljava/lang/IllegalArgumentException;",
+ Thread::Current()->ThrowNewExceptionF("Ljava/lang/IllegalArgumentException;",
"invalid primitive conversion from %s to %s",
PrettyDescriptor(src_class->GetDescriptor()).c_str(),
PrettyDescriptor(dst_class->GetDescriptor()).c_str());
@@ -333,7 +333,7 @@
src_class = class_linker->FindPrimitiveClass('S');
boxed_value.s = primitive_field->GetShort(o);
} else {
- Thread::Current()->ThrowNewException("Ljava/lang/IllegalArgumentException;",
+ Thread::Current()->ThrowNewExceptionF("Ljava/lang/IllegalArgumentException;",
"%s is not a boxed primitive type", PrettyDescriptor(src_descriptor).c_str());
return false;
}