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
diff --git a/core/jni/android_os_SystemProperties.cpp b/core/jni/android_os_SystemProperties.cpp
index 3c4d2bf..66af965 100644
--- a/core/jni/android_os_SystemProperties.cpp
+++ b/core/jni/android_os_SystemProperties.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2006, The Android Open Source Project
**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
**
-** http://www.apache.org/licenses/LICENSE-2.0
+** http://www.apache.org/licenses/LICENSE-2.0
**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
** limitations under the License.
*/
@@ -32,8 +32,7 @@
jstring rvJ = NULL;
if (keyJ == NULL) {
- jniThrowException(env, "java/lang/NullPointerException",
- "key must not be null.");
+ jniThrowNullPointerException(env, "key must not be null.");
goto error;
}
@@ -69,8 +68,7 @@
jint result = defJ;
if (keyJ == NULL) {
- jniThrowException(env, "java/lang/NullPointerException",
- "key must not be null.");
+ jniThrowNullPointerException(env, "key must not be null.");
goto error;
}
@@ -98,8 +96,7 @@
jlong result = defJ;
if (keyJ == NULL) {
- jniThrowException(env, "java/lang/NullPointerException",
- "key must not be null.");
+ jniThrowNullPointerException(env, "key must not be null.");
goto error;
}
@@ -127,8 +124,7 @@
jboolean result = defJ;
if (keyJ == NULL) {
- jniThrowException(env, "java/lang/NullPointerException",
- "key must not be null.");
+ jniThrowNullPointerException(env, "key must not be null.");
goto error;
}
@@ -163,8 +159,7 @@
const char* val;
if (keyJ == NULL) {
- jniThrowException(env, "java/lang/NullPointerException",
- "key must not be null.");
+ jniThrowNullPointerException(env, "key must not be null.");
return ;
}
key = env->GetStringUTFChars(keyJ, NULL);