Fix jniThrowRuntimeException for C callers, add jniThrowNullPointerException.
...and switch all NPE throwers over to the helper.
diff --git a/JNIHelp.c b/JNIHelp.c
index d0e2f89..a75b837 100644
--- a/JNIHelp.c
+++ b/JNIHelp.c
@@ -133,6 +133,14 @@
}
/*
+ * Throw a java.lang.NullPointerException, with an optional message.
+ */
+int jniThrowNullPointerException(JNIEnv* env, const char* msg)
+{
+ return jniThrowException(env, "java/lang/NullPointerException", msg);
+}
+
+/*
* Throw a java.lang.RuntimeException, with an optional message.
*/
int jniThrowRuntimeException(JNIEnv* env, const char* msg)
diff --git a/include/nativehelper/JNIHelp.h b/include/nativehelper/JNIHelp.h
index 3d8983f..59c2620 100644
--- a/include/nativehelper/JNIHelp.h
+++ b/include/nativehelper/JNIHelp.h
@@ -54,9 +54,14 @@
int jniThrowException(C_JNIEnv* env, const char* className, const char* msg);
/*
+ * Throw a java.lang.NullPointerException, with an optional message.
+ */
+int jniThrowNullPointerException(C_JNIEnv* env, const char* msg);
+
+/*
* Throw a java.lang.RuntimeException, with an optional message.
*/
-int jniThrowRuntimeException(JNIEnv* env, const char* msg);
+int jniThrowRuntimeException(C_JNIEnv* env, const char* msg);
/*
* Throw a java.io.IOException, generating the message from errno.
@@ -107,6 +112,14 @@
{
return jniThrowException(&env->functions, className, msg);
}
+inline int jniThrowNullPointerException(JNIEnv* env, const char* msg)
+{
+ return jniThrowNullPointerException(&env->functions, msg);
+}
+inline int jniThrowRuntimeException(JNIEnv* env, const char* msg)
+{
+ return jniThrowRuntimeException(&env->functions, msg);
+}
inline int jniThrowIOException(JNIEnv* env, int errnum)
{
return jniThrowIOException(&env->functions, errnum);