--- old/src/java.desktop/macosx/native/libawt_lwawt/awt/CInputMethod.m 2017-02-13 16:48:06.000000000 +0300 +++ new/src/java.desktop/macosx/native/libawt_lwawt/awt/CInputMethod.m 2017-02-13 16:48:06.000000000 +0300 @@ -299,10 +299,22 @@ jobject returnValue = 0; __block NSArray *selectableArray = nil; + __block NSString *currentLocale = nil; JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ selectableArray = (NSArray *)[inputMethodController performSelector:@selector(availableInputMethodLocales)]; + // If it is impossible to retirieve the list of available input method locales from + // the platform for some reason, we will return the array contained only current locale. + if ([selectableArray count] == 0) { + currentLocale = (NSString *) [inputMethodController performSelector:@selector(currentInputMethodLocale)]; + if ([currentLocale length] != 0) { + selectableArray = [NSArray arrayWithObjects:currentLocale, nil]; + [currentLocale retain]; + } else { + [currentLocale release]; + } + } [selectableArray retain]; }]; @@ -323,6 +335,7 @@ (*env)->DeleteLocalRef(env, localeObj); } + [currentLocale release]; [selectableArray release]; JNF_COCOA_EXIT(env); return returnValue;