From 21f60042fdb269b745fa3c518735c8e9239abb4f Mon Sep 17 00:00:00 2001 From: serb Date: Wed, 12 Mar 2014 15:43:53 +0400 Subject: [PATCH] 8034214: [parfait] JNI exception pending in jdk/src/macosx/native/sun/awt/CInputMethod.m Reviewed-by: pchelko, azvegint --- src/macosx/native/sun/awt/CInputMethod.m | 39 +++++++++++++++--------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/macosx/native/sun/awt/CInputMethod.m b/src/macosx/native/sun/awt/CInputMethod.m index 512c814ba..f4c3e7f18 100644 --- a/src/macosx/native/sun/awt/CInputMethod.m +++ b/src/macosx/native/sun/awt/CInputMethod.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -70,17 +70,23 @@ static jobject CreateLocaleObjectFromNSString(JNIEnv *env, NSString *name) } // Create the java.util.Locale object + jobject localeObj = NULL; jobject langObj = (*env)->NewStringUTF(env, language); - jobject ctryObj = (*env)->NewStringUTF(env, country); - jobject vrntObj = (*env)->NewStringUTF(env, variant); - jobject localeObj = JNFNewObject(env, jm_localeCons, langObj, ctryObj, vrntObj); // AWT_THREADING Safe (known object) - + if (langObj != NULL) { + jobject ctryObj = (*env)->NewStringUTF(env, country); + if(ctryObj != NULL) { + jobject vrntObj = (*env)->NewStringUTF(env, variant); + if (vrntObj != NULL) { + localeObj = JNFNewObject(env, jm_localeCons,langObj, ctryObj, + vrntObj); + (*env)->DeleteLocalRef(env, vrntObj); + } + (*env)->DeleteLocalRef(env, ctryObj); + } + (*env)->DeleteLocalRef(env, langObj); + } // Clean up and return. free(language); - (*env)->DeleteLocalRef(env, langObj); - (*env)->DeleteLocalRef(env, ctryObj); - (*env)->DeleteLocalRef(env, vrntObj); - return localeObj; } @@ -234,10 +240,12 @@ JNF_COCOA_ENTER(env); if (sLastKeyboardLocaleObj) { JNFDeleteGlobalRef(env, sLastKeyboardLocaleObj); + sLastKeyboardLocaleObj = NULL; + } + if (localObj != NULL) { + sLastKeyboardLocaleObj = JNFNewGlobalRef(env, localObj); + (*env)->DeleteLocalRef(env, localObj); } - - sLastKeyboardLocaleObj = JNFNewGlobalRef(env, localObj); - (*env)->DeleteLocalRef(env, localObj); } returnValue = sLastKeyboardLocaleObj; @@ -305,9 +313,12 @@ JNF_COCOA_ENTER(env); for(NSString *locale in selectableArray) { jobject localeObj = CreateLocaleObjectFromNSString(env, locale); + if (localeObj == NULL) { + break; + } - if (JNFCallBooleanMethod(env, returnValue, jm_listContains, localeObj) == JNI_FALSE) { // AWT_THREADING Safe (known object) - JNFCallBooleanMethod(env, returnValue, jm_listAdd, localeObj); // AWT_THREADING Safe (known object) + if (JNFCallBooleanMethod(env, returnValue, jm_listContains, localeObj) == JNI_FALSE) { + JNFCallBooleanMethod(env, returnValue, jm_listAdd, localeObj); } (*env)->DeleteLocalRef(env, localeObj); -- GitLab