diff options
author | Elliott Hughes <enh@google.com> | 2009-10-01 11:20:29 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2009-10-01 11:20:29 -0700 |
commit | 738f95037e3e00ec5ccb8686f7c4c5c2cc16e06a (patch) | |
tree | a803f5fda92fe4a84c6f00d76db4f8e20e4a61ae /luni | |
parent | 109fc1115e7afd2907544b805eaa2cc8a0e2635f (diff) | |
download | libcore-738f95037e3e00ec5ccb8686f7c4c5c2cc16e06a.zip libcore-738f95037e3e00ec5ccb8686f7c4c5c2cc16e06a.tar.gz libcore-738f95037e3e00ec5ccb8686f7c4c5c2cc16e06a.tar.bz2 |
Use jniThrowException instead of FindClass/ThrowNew.
Always use our best-of-breed code for throwing exceptions. The remaining
callers of Throw have good reason, and the only caller of ThrowNew is
now JNIHelp.c (jniThrowException) itself.
Diffstat (limited to 'luni')
-rw-r--r-- | luni/src/main/native/java_net_InetAddress.cpp | 17 | ||||
-rw-r--r-- | luni/src/main/native/java_net_NetworkInterface.c | 24 |
2 files changed, 4 insertions, 37 deletions
diff --git a/luni/src/main/native/java_net_InetAddress.cpp b/luni/src/main/native/java_net_InetAddress.cpp index 243b63d..4e58a1f 100644 --- a/luni/src/main/native/java_net_InetAddress.cpp +++ b/luni/src/main/native/java_net_InetAddress.cpp @@ -47,19 +47,6 @@ static jstring InetAddress_gethostname(JNIEnv* env, jobject obj) } } -static void throwNullPointerException(JNIEnv* env) -{ - const char* className = "java/lang/NullPointerException"; - - jclass exClass = env->FindClass(className); - - if (exClass == NULL) { - LOGE("Unable to find class %s", className); - } else { - env->ThrowNew(exClass, NULL); - } -} - #if LOG_DNS static void logIpString(struct addrinfo* ai, const char* name) { @@ -207,7 +194,7 @@ jobjectArray InetAddress_getallbyname(JNIEnv* env, jobject obj, jboolean preferIPv4Stack) { if (javaName == NULL) { - throwNullPointerException(env); + jniThrowException(env, "java/lang/NullPointerException", NULL); return NULL; } @@ -246,7 +233,7 @@ static jstring InetAddress_gethostbyaddr(JNIEnv* env, jobject obj, jbyteArray javaAddress) { if (javaAddress == NULL) { - throwNullPointerException(env); + jniThrowException(env, "java/lang/NullPointerException", NULL); return NULL; } diff --git a/luni/src/main/native/java_net_NetworkInterface.c b/luni/src/main/native/java_net_NetworkInterface.c index c659ae1..7fdf4fe 100644 --- a/luni/src/main/native/java_net_NetworkInterface.c +++ b/luni/src/main/native/java_net_NetworkInterface.c @@ -34,27 +34,7 @@ * Throws an IOException with the given message. */ static void throwSocketException(JNIEnv *env, const char *message) { - jclass exClass = (*env)->FindClass(env, "java/net/SocketException"); - - if(exClass == NULL) { - LOGE("Unable to find class java/net/SocketException"); - } else { - (*env)->ThrowNew(env, exClass, message); - } -} - - -/** - * Throws a NullPointerException. - */ -static void throwNullPointerException(JNIEnv *env) { - jclass exClass = (*env)->FindClass(env, "java/lang/NullPointerException"); - - if(exClass == NULL) { - LOGE("Unable to find class java/lang/NullPointerException"); - } else { - (*env)->ThrowNew(env, exClass, NULL); - } + jniThrowException(env, "java/net/SocketException", message); } /** @@ -242,7 +222,7 @@ static int structInToJavaAddress( JNIEnv *env, struct in_addr *address, jbyteArray java_address) { if (java_address == NULL) { - throwNullPointerException(env); + jniThrowException(env, "java/lang/NullPointerException", NULL); return -1; } |