From fd746a2fe0e4c1c056065da93e2be2d8bb4e5428 Mon Sep 17 00:00:00 2001 From: Artem Semenov Date: Fri, 23 Dec 2022 22:07:14 +0000 Subject: [PATCH] 8298643: JNI call of getAccessibleRowWithIndex and getAccessibleColumnWithIndex on a wrong thread Reviewed-by: serb, kizune --- .../awt/a11y/TableAccessibility.m | 28 +++++++------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/TableAccessibility.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/TableAccessibility.m index 6ca5e3ee2a9..36af3dd5f10 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/TableAccessibility.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/TableAccessibility.m @@ -88,28 +88,20 @@ static jmethodID sjm_getAccessibleName = NULL; - (int)accessibleRowAtIndex:(int)index { - JNIEnv *env = [ThreadUtilities getJNIEnv]; - jobject axContext = [self axContextWithEnv:env]; - if (axContext == NULL) return 0; - jclass clsInfo = (*env)->GetObjectClass(env, axContext); - DECLARE_METHOD_RETURN(jm_getAccessibleRowAtIndex, clsInfo, "getAccessibleRowAtIndex", "(I)I", -1); - jint rowAtIndex = (*env)->CallIntMethod(env, axContext, jm_getAccessibleRowAtIndex, (jint)index); - CHECK_EXCEPTION(); - (*env)->DeleteLocalRef(env, axContext); - return (int)rowAtIndex; + int columnCount = [self accessibilityColumnCount]; + if (columnCount != 0) { + return index / columnCount; + } + return -1; } - (int)accessibleColumnAtIndex:(int)index { - JNIEnv *env = [ThreadUtilities getJNIEnv]; - jobject axContext = [self axContextWithEnv:env]; - if (axContext == NULL) return 0; - jclass clsInfo = (*env)->GetObjectClass(env, axContext); - DECLARE_METHOD_RETURN(jm_getAccessibleColumnAtIndex, clsInfo, "getAccessibleColumnAtIndex", "(I)I", -1); - jint columnAtIndex = (*env)->CallIntMethod(env, axContext, jm_getAccessibleColumnAtIndex, (jint)index); - CHECK_EXCEPTION(); - (*env)->DeleteLocalRef(env, axContext); - return (int)columnAtIndex; + int columnCount = [self accessibilityColumnCount]; + if (columnCount != 0) { + return index % columnCount; + } + return -1; } - (BOOL) isAccessibleChildSelectedFromIndex:(int)index