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_pim_EventRecurrence.cpp b/core/jni/android_pim_EventRecurrence.cpp
index cbe99bc..9056c90 100644
--- a/core/jni/android_pim_EventRecurrence.cpp
+++ b/core/jni/android_pim_EventRecurrence.cpp
@@ -1,17 +1,17 @@
 /* //device/libs/android_runtime/android_pim_EventRecurrence.cpp

 **

-** Copyright 2006, The Android Open Source Project
+** 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.

 */

 

@@ -84,8 +84,7 @@
 EventRecurrence_parse(JNIEnv* env, jobject This, jstring jstr)

 {

     if (jstr == NULL) {

-        jniThrowException(env, "java/lang/NullPointerException", 

-                "EventRecurrence.parse str parameter null"); 

+        jniThrowNullPointerException(env, "EventRecurrence.parse str parameter null");

         return ;

     }

     jboolean isCopy;

@@ -112,8 +111,8 @@
     if (er.until.size() > 0) {

         untilStr = env->NewString(er.until.string(), er.until.size());

         if (untilStr == NULL) {

-            jniThrowException(env, "java/lang/RuntimeException", 

-                    "EventRecurrence.parse error setting field 'until'"); 

+            jniThrowException(env, "java/lang/RuntimeException",

+                    "EventRecurrence.parse error setting field 'until'");

             return ;

         }

     } else {

@@ -132,7 +131,7 @@
     SET_ARRAY_AND_CHECK(byday)

     // we'll just set the bydayCount field twice, it'll be less code total

     if (set_array(env, er.bydayCount, er.bydayNum, This, bydayNum_fields)

-            != NO_ERROR) { 

+            != NO_ERROR) {

         jniThrowException(env, "java/lang/RuntimeException",

                 "EventRecurrence.parse error setting field bydayNum or "

                 "bydayCount.");

@@ -196,4 +195,3 @@
 }

 

 }; // namespace android

-