diff options
author | Elliott Hughes <enh@google.com> | 2011-04-08 14:10:28 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2011-04-08 15:01:19 -0700 |
commit | 69a017bc1d1649350f830dfada5c6ed5eac0b770 (patch) | |
tree | 6ecc6d9658272b268ce931d417930e2ea1bfa3f7 /core/jni/android_util_Binder.cpp | |
parent | 5008e92d1fd573d926cd55c39ca723a6fbdf7c4b (diff) | |
download | frameworks_base-69a017bc1d1649350f830dfada5c6ed5eac0b770.zip frameworks_base-69a017bc1d1649350f830dfada5c6ed5eac0b770.tar.gz frameworks_base-69a017bc1d1649350f830dfada5c6ed5eac0b770.tar.bz2 |
More JNI exception-throwing cleanup.
There are a few (unimportant) bug fixes here. There were several attempts to
throw exceptions in situations where there's already a pending exception.
There were also cases where the code was wrong; it was checking for a NULL
return from Get*ArrayElements and throwing NPE, but passing NULL is an error
that causes a crash and a NULL return means an exception has already been
thrown. I didn't want to get into the Scoped* classes just yet, but that
was by far the easiest way to fix this.
Change-Id: I0b31160ee51b96e82539f6514b8412b149dba7c3
Diffstat (limited to 'core/jni/android_util_Binder.cpp')
-rw-r--r-- | core/jni/android_util_Binder.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp index eb1c437..8618b79 100644 --- a/core/jni/android_util_Binder.cpp +++ b/core/jni/android_util_Binder.cpp @@ -993,7 +993,7 @@ static jboolean android_os_BinderProxy_transact(JNIEnv* env, jobject obj, jobject replyObj, jint flags) { if (dataObj == NULL) { - jniThrowException(env, "java/lang/NullPointerException", NULL); + jniThrowNullPointerException(env, NULL); return JNI_FALSE; } @@ -1045,7 +1045,7 @@ static void android_os_BinderProxy_linkToDeath(JNIEnv* env, jobject obj, jobject recipient, jint flags) { if (recipient == NULL) { - jniThrowException(env, "java/lang/NullPointerException", NULL); + jniThrowNullPointerException(env, NULL); return; } @@ -1077,7 +1077,7 @@ static jboolean android_os_BinderProxy_unlinkToDeath(JNIEnv* env, jobject obj, { jboolean res = JNI_FALSE; if (recipient == NULL) { - jniThrowException(env, "java/lang/NullPointerException", NULL); + jniThrowNullPointerException(env, NULL); return res; } @@ -1166,7 +1166,7 @@ static int int_register_android_os_BinderProxy(JNIEnv* env) clazz = env->FindClass("java/lang/Error"); LOG_FATAL_IF(clazz == NULL, "Unable to find class java.lang.Error"); gErrorOffsets.mClass = (jclass) env->NewGlobalRef(clazz); - + clazz = env->FindClass(kBinderProxyPathName); LOG_FATAL_IF(clazz == NULL, "Unable to find class android.os.BinderProxy"); @@ -1474,7 +1474,7 @@ static jobject android_os_Parcel_openFileDescriptor(JNIEnv* env, jobject clazz, jstring name, jint mode) { if (name == NULL) { - jniThrowException(env, "java/lang/NullPointerException", NULL); + jniThrowNullPointerException(env, NULL); return NULL; } const jchar* str = env->GetStringCritical(name, 0); @@ -1522,7 +1522,7 @@ static jobject android_os_Parcel_openFileDescriptor(JNIEnv* env, jobject clazz, static jobject android_os_Parcel_dupFileDescriptor(JNIEnv* env, jobject clazz, jobject orig) { if (orig == NULL) { - jniThrowException(env, "java/lang/NullPointerException", NULL); + jniThrowNullPointerException(env, NULL); return NULL; } int origfd = env->GetIntField(orig, gFileDescriptorOffsets.mDescriptor); @@ -1533,7 +1533,7 @@ static jobject android_os_Parcel_dupFileDescriptor(JNIEnv* env, jobject clazz, j int fd = dup(origfd); if (fd < 0) { - jniThrowException(env, "java/io/IOException", strerror(errno)); + jniThrowIOException(env, errno); return NULL; } jobject object = newFileDescriptor(env, fd); @@ -1546,7 +1546,7 @@ static jobject android_os_Parcel_dupFileDescriptor(JNIEnv* env, jobject clazz, j static void android_os_Parcel_closeFileDescriptor(JNIEnv* env, jobject clazz, jobject object) { if (object == NULL) { - jniThrowException(env, "java/lang/NullPointerException", NULL); + jniThrowNullPointerException(env, NULL); return; } int fd = env->GetIntField(object, gFileDescriptorOffsets.mDescriptor); @@ -1560,7 +1560,7 @@ static void android_os_Parcel_closeFileDescriptor(JNIEnv* env, jobject clazz, jo static void android_os_Parcel_clearFileDescriptor(JNIEnv* env, jobject clazz, jobject object) { if (object == NULL) { - jniThrowException(env, "java/lang/NullPointerException", NULL); + jniThrowNullPointerException(env, NULL); return; } int fd = env->GetIntField(object, gFileDescriptorOffsets.mDescriptor); |