summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2014-08-20 10:04:08 -0700
committerMathieu Chartier <mathieuc@google.com>2014-08-20 16:24:47 -0700
commit98671c34fa00a79c62ff0d9d874428bed1f86e92 (patch)
tree6f7ce03165b1656e210e7b6e82e8dada8d0f5667
parent8f9ebc8a7c0238ce85104d2f20d0ddad1e4d8696 (diff)
downloadbase-98671c34fa00a79c62ff0d9d874428bed1f86e92.tar.gz
Clean up ExceptionOccurred.
Use ExceptionCheck before ExceptionOccurred since ExceptionCheck doesn't acquire any locks and is faster. Change-Id: Ibd87fd1e33b339bd2a6effa1d20d3253c8a61bdc
-rw-r--r--core/jni/android_net_LocalSocketImpl.cpp44
-rw-r--r--core/jni/android_os_MessageQueue.cpp4
-rw-r--r--core/jni/android_os_SELinux.cpp2
-rw-r--r--core/jni/android_server_NetworkManagementSocketTagger.cpp4
-rw-r--r--core/jni/android_util_Binder.cpp16
-rw-r--r--core/jni/com_android_internal_os_ZygoteInit.cpp18
6 files changed, 44 insertions, 44 deletions
diff --git a/core/jni/android_net_LocalSocketImpl.cpp b/core/jni/android_net_LocalSocketImpl.cpp
index 98f4bed1fc90..a408a96cd2fa 100644
--- a/core/jni/android_net_LocalSocketImpl.cpp
+++ b/core/jni/android_net_LocalSocketImpl.cpp
@@ -57,7 +57,7 @@ socket_connect_local(JNIEnv *env, jobject object,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -95,7 +95,7 @@ socket_bind_local (JNIEnv *env, jobject object, jobject fileDescriptor,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -118,7 +118,7 @@ socket_listen (JNIEnv *env, jobject object, jobject fileDescriptor, jint backlog
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -154,7 +154,7 @@ socket_accept (JNIEnv *env, jobject object, jobject fileDescriptor, jobject s)
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return NULL;
}
@@ -184,7 +184,7 @@ socket_shutdown (JNIEnv *env, jobject object, jobject fileDescriptor,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -246,7 +246,7 @@ socket_getOption(JNIEnv *env, jobject object, jobject fileDescriptor, jint optID
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return 0;
}
@@ -293,7 +293,7 @@ static void socket_setOption(
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -353,7 +353,7 @@ static jint socket_pending (JNIEnv *env, jobject object,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return (jint)-1;
}
@@ -378,7 +378,7 @@ static jint socket_available (JNIEnv *env, jobject object,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return (jint)-1;
}
@@ -459,20 +459,20 @@ static int socket_process_cmsg(JNIEnv *env, jobject thisJ, struct msghdr * pMsg)
jobject fdObject
= jniCreateFileDescriptor(env, pDescriptors[i]);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
env->SetObjectArrayElement(fdArray, i, fdObject);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
}
env->SetObjectField(thisJ, field_inboundFileDescriptors, fdArray);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
}
@@ -558,7 +558,7 @@ static int socket_write_all(JNIEnv *env, jobject object, int fd,
= (jobjectArray)env->GetObjectField(
object, field_outboundFileDescriptors);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
@@ -570,18 +570,18 @@ static int socket_write_all(JNIEnv *env, jobject object, int fd,
// Add any pending outbound file descriptors to the message
if (outboundFds != NULL) {
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
for (int i = 0; i < countFds; i++) {
jobject fdObject = env->GetObjectArrayElement(outboundFds, i);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
fds[i] = jniGetFDFromFileDescriptor(env, fdObject);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
}
@@ -638,7 +638,7 @@ static jint socket_read (JNIEnv *env, jobject object, jobject fileDescriptor)
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return (jint)0;
}
@@ -683,7 +683,7 @@ static jint socket_readba (JNIEnv *env, jobject object,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return (jint)-1;
}
@@ -717,7 +717,7 @@ static void socket_write (JNIEnv *env, jobject object,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -745,7 +745,7 @@ static void socket_writeba (JNIEnv *env, jobject object,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -777,7 +777,7 @@ static jobject socket_get_peer_credentials(JNIEnv *env,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return NULL;
}
@@ -816,7 +816,7 @@ static jobject socket_getSockName(JNIEnv *env,
fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return NULL;
}
diff --git a/core/jni/android_os_MessageQueue.cpp b/core/jni/android_os_MessageQueue.cpp
index a8ed89554261..15d62a2bd476 100644
--- a/core/jni/android_os_MessageQueue.cpp
+++ b/core/jni/android_os_MessageQueue.cpp
@@ -54,8 +54,8 @@ MessageQueue::~MessageQueue() {
}
bool MessageQueue::raiseAndClearException(JNIEnv* env, const char* msg) {
- jthrowable exceptionObj = env->ExceptionOccurred();
- if (exceptionObj) {
+ if (env->ExceptionCheck()) {
+ jthrowable exceptionObj = env->ExceptionOccurred();
env->ExceptionClear();
raiseException(env, msg, exceptionObj);
env->DeleteLocalRef(exceptionObj);
diff --git a/core/jni/android_os_SELinux.cpp b/core/jni/android_os_SELinux.cpp
index 26405b59a386..cebcaae70037 100644
--- a/core/jni/android_os_SELinux.cpp
+++ b/core/jni/android_os_SELinux.cpp
@@ -97,7 +97,7 @@ static jstring getPeerCon(JNIEnv *env, jobject, jobject fileDescriptor) {
}
int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
ALOGE("getPeerCon => getFD for %p failed", fileDescriptor);
return NULL;
}
diff --git a/core/jni/android_server_NetworkManagementSocketTagger.cpp b/core/jni/android_server_NetworkManagementSocketTagger.cpp
index 7e12b1ea71b6..ca21fd716a5f 100644
--- a/core/jni/android_server_NetworkManagementSocketTagger.cpp
+++ b/core/jni/android_server_NetworkManagementSocketTagger.cpp
@@ -35,7 +35,7 @@ static jint QTagUid_tagSocketFd(JNIEnv* env, jclass,
jint tagNum, jint uid) {
int userFd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
ALOGE("Can't get FileDescriptor num");
return (jint)-1;
}
@@ -51,7 +51,7 @@ static jint QTagUid_untagSocketFd(JNIEnv* env, jclass,
jobject fileDescriptor) {
int userFd = jniGetFDFromFileDescriptor(env, fileDescriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
ALOGE("Can't get FileDescriptor num");
return (jint)-1;
}
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp
index e0003b8150ac..fbe55e2f3aed 100644
--- a/core/jni/android_util_Binder.cpp
+++ b/core/jni/android_util_Binder.cpp
@@ -272,9 +272,9 @@ protected:
//printf("\n");
jboolean res = env->CallBooleanMethod(mObject, gBinderOffsets.mExecTransact,
code, reinterpret_cast<jlong>(&data), reinterpret_cast<jlong>(reply), flags);
- jthrowable excep = env->ExceptionOccurred();
- if (excep) {
+ if (env->ExceptionCheck()) {
+ jthrowable excep = env->ExceptionOccurred();
report_exception(env, excep,
"*** Uncaught remote exception! "
"(Exceptions are not yet supported across processes.)");
@@ -296,12 +296,12 @@ protected:
set_dalvik_blockguard_policy(env, strict_policy_before);
}
- jthrowable excep2 = env->ExceptionOccurred();
- if (excep2) {
- report_exception(env, excep2,
+ if (env->ExceptionCheck()) {
+ jthrowable excep = env->ExceptionOccurred();
+ report_exception(env, excep,
"*** Uncaught exception in onBinderStrictModePolicyChange");
/* clean up JNI local ref -- we don't return to Java code */
- env->DeleteLocalRef(excep2);
+ env->DeleteLocalRef(excep);
}
// Need to always call through the native implementation of
@@ -403,8 +403,8 @@ public:
env->CallStaticVoidMethod(gBinderProxyOffsets.mClass,
gBinderProxyOffsets.mSendDeathNotice, mObject);
- jthrowable excep = env->ExceptionOccurred();
- if (excep) {
+ if (env->ExceptionCheck()) {
+ jthrowable excep = env->ExceptionOccurred();
report_exception(env, excep,
"*** Uncaught exception returned from death notification!");
}
diff --git a/core/jni/com_android_internal_os_ZygoteInit.cpp b/core/jni/com_android_internal_os_ZygoteInit.cpp
index 2233ee3e012b..10c6e2ce3a83 100644
--- a/core/jni/com_android_internal_os_ZygoteInit.cpp
+++ b/core/jni/com_android_internal_os_ZygoteInit.cpp
@@ -96,7 +96,7 @@ static void com_android_internal_os_ZygoteInit_reopenStdio(JNIEnv* env,
fd = jniGetFDFromFileDescriptor(env, in);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -106,7 +106,7 @@ static void com_android_internal_os_ZygoteInit_reopenStdio(JNIEnv* env,
fd = jniGetFDFromFileDescriptor(env, out);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -116,7 +116,7 @@ static void com_android_internal_os_ZygoteInit_reopenStdio(JNIEnv* env,
fd = jniGetFDFromFileDescriptor(env, errfd);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -134,7 +134,7 @@ static void com_android_internal_os_ZygoteInit_setCloseOnExec (JNIEnv *env,
fd = jniGetFDFromFileDescriptor(env, descriptor);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return;
}
@@ -170,7 +170,7 @@ static jint com_android_internal_os_ZygoteInit_selectReadable (
jsize length = env->GetArrayLength(fds);
fd_set fdset;
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
@@ -179,14 +179,14 @@ static jint com_android_internal_os_ZygoteInit_selectReadable (
int nfds = 0;
for (jsize i = 0; i < length; i++) {
jobject fdObj = env->GetObjectArrayElement(fds, i);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
if (fdObj == NULL) {
continue;
}
int fd = jniGetFDFromFileDescriptor(env, fdObj);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
@@ -209,14 +209,14 @@ static jint com_android_internal_os_ZygoteInit_selectReadable (
for (jsize i = 0; i < length; i++) {
jobject fdObj = env->GetObjectArrayElement(fds, i);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
if (fdObj == NULL) {
continue;
}
int fd = jniGetFDFromFileDescriptor(env, fdObj);
- if (env->ExceptionOccurred() != NULL) {
+ if (env->ExceptionCheck()) {
return -1;
}
if (FD_ISSET(fd, &fdset)) {