changeset 9588:d0dbd097b6aa

8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m Reviewed-by: pchelko, azvegint
author serb
date Thu, 06 Mar 2014 15:05:41 +0400
parents b55028013a00
children 2e464ef54988
files src/macosx/native/sun/awt/AWTEvent.m src/macosx/native/sun/awt/AWTView.m
diffstat 2 files changed, 32 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/native/sun/awt/AWTEvent.m	Thu Mar 06 14:47:43 2014 +0400
+++ b/src/macosx/native/sun/awt/AWTEvent.m	Thu Mar 06 15:05:41 2014 +0400
@@ -28,6 +28,7 @@
 #import <sys/time.h>
 #include <Carbon/Carbon.h>
 
+#import "jni_util.h" 
 #import "LWCToolkit.h"
 #import "ThreadUtilities.h"
 
@@ -687,6 +688,7 @@
 
     jboolean copy = JNI_FALSE;
     jint *data = (*env)->GetIntArrayElements(env, inData, &copy);
+    CHECK_NULL_RETURN(data, postsTyped);
 
     // in  = [testChar, testDeadChar, modifierFlags, keyCode]
     jchar testChar = (jchar)data[0];
@@ -727,6 +729,7 @@
 
     jboolean copy = JNI_FALSE;
     jint *data = (*env)->GetIntArrayElements(env, inData, &copy);
+    CHECK_NULL(data);
 
     // in  = [modifierFlags, keyCode]
     jint modifierFlags = data[0];
--- a/src/macosx/native/sun/awt/AWTView.m	Thu Mar 06 14:47:43 2014 +0400
+++ b/src/macosx/native/sun/awt/AWTView.m	Thu Mar 06 15:05:41 2014 +0400
@@ -1081,21 +1081,22 @@
     jarray array;
     jboolean isCopy;
     jint *_array;
-    NSRange range;
+    NSRange range = NSMakeRange(NSNotFound, 0);
 
     array = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_markedRange); // AWT_THREADING Safe (AWTRunLoopMode)
 
     if (array) {
         _array = (*env)->GetIntArrayElements(env, array, &isCopy);
-        range = NSMakeRange(_array[0], _array[1]);
-
+        if (_array != NULL) {
+            range.location = _array[0];
+            range.length = _array[1];
 #ifdef IM_DEBUG
-        fprintf(stderr, "markedRange returning (%lu, %lu)\n", (unsigned long)range.location, (unsigned long)range.length);
+            fprintf(stderr, "markedRange returning (%lu, %lu)\n",
+                    (unsigned long)range.location, (unsigned long)range.length);
 #endif // IM_DEBUG
-        (*env)->ReleaseIntArrayElements(env, array, _array, 0);
+            (*env)->ReleaseIntArrayElements(env, array, _array, 0);
+        }
         (*env)->DeleteLocalRef(env, array);
-    } else {
-        range = NSMakeRange(NSNotFound, 0);
     }
 
     return range;
@@ -1115,7 +1116,7 @@
     jarray array;
     jboolean isCopy;
     jint *_array;
-    NSRange range;
+    NSRange range = NSMakeRange(NSNotFound, 0);
 
 #ifdef IM_DEBUG
     fprintf(stderr, "AWTView InputMethod Selector Called : [selectedRange]\n");
@@ -1124,15 +1125,15 @@
     array = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_selectedRange); // AWT_THREADING Safe (AWTRunLoopMode)
     if (array) {
         _array = (*env)->GetIntArrayElements(env, array, &isCopy);
-        range = NSMakeRange(_array[0], _array[1]);
-        (*env)->ReleaseIntArrayElements(env, array, _array, 0);
+        if (_array != NULL) {
+            range.location = _array[0];
+            range.length = _array[1];
+            (*env)->ReleaseIntArrayElements(env, array, _array, 0);
+        }
         (*env)->DeleteLocalRef(env, array);
-    } else {
-        range = NSMakeRange(NSNotFound, 0);
     }
 
     return range;
-
 }
 
 /* This method returns the first frame of rects for theRange in screen coordindate system.
@@ -1140,7 +1141,7 @@
 - (NSRect) firstRectForCharacterRange:(NSRange)theRange actualRange:(NSRangePointer)actualRange
 {
     if (!fInputMethodLOCKABLE) {
-        return NSMakeRect(0, 0, 0, 0);
+        return NSZeroRect;
     }
 
     static JNF_MEMBER_CACHE(jm_firstRectForCharacterRange, jc_CInputMethod,
@@ -1152,18 +1153,27 @@
     NSRect rect;
 
 #ifdef IM_DEBUG
-    fprintf(stderr, "AWTView InputMethod Selector Called : [firstRectForCharacterRange:] location=%lu, length=%lu\n", (unsigned long)theRange.location, (unsigned long)theRange.length);
+    fprintf(stderr,
+            "AWTView InputMethod Selector Called : [firstRectForCharacterRange:] location=%lu, length=%lu\n",
+            (unsigned long)theRange.location, (unsigned long)theRange.length);
 #endif // IM_DEBUG
 
-    array = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_firstRectForCharacterRange, theRange.location); // AWT_THREADING Safe (AWTRunLoopMode)
+    array = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_firstRectForCharacterRange,
+                                theRange.location); // AWT_THREADING Safe (AWTRunLoopMode)
 
     _array = (*env)->GetIntArrayElements(env, array, &isCopy);
-    rect = ConvertNSScreenRect(env, NSMakeRect(_array[0], _array[1], _array[2], _array[3]));
-    (*env)->ReleaseIntArrayElements(env, array, _array, 0);
+    if (_array) {
+        rect = ConvertNSScreenRect(env, NSMakeRect(_array[0], _array[1], _array[2], _array[3]));
+        (*env)->ReleaseIntArrayElements(env, array, _array, 0);
+    } else {
+        rect = NSZeroRect;
+    }
     (*env)->DeleteLocalRef(env, array);
 
 #ifdef IM_DEBUG
-    fprintf(stderr, "firstRectForCharacterRange returning x=%f, y=%f, width=%f, height=%f\n", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
+    fprintf(stderr,
+            "firstRectForCharacterRange returning x=%f, y=%f, width=%f, height=%f\n",
+            rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
 #endif // IM_DEBUG
     return rect;
 }