Skip to content
Permalink
Browse files
8274383: JNI call of getAccessibleSelection on a wrong thread
Reviewed-by: kizune
Backport-of: b36881fa3b3f37400d4f2c0bca3192d88179f2ff
  • Loading branch information
savoptik authored and Anton Tarasov committed Nov 19, 2021
1 parent b7c7b84 commit ddc81f2788b7909146d82b4b45c7c3a14db09c21
Showing 1 changed file with 16 additions and 4 deletions.
@@ -35,6 +35,12 @@
GET_STATIC_METHOD_RETURN(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", \
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;", ret);

static jmethodID sjm_getAccessibleSelection = NULL;
#define GET_ACCESSIBLESELECTION_METHOD_RETURN(ret) \
GET_CACCESSIBILITY_CLASS_RETURN(ret); \
GET_STATIC_METHOD_RETURN(sjm_getAccessibleSelection, sjc_CAccessibility, "getAccessibleSelection", \
"(Ljavax/accessibility/AccessibleContext;Ljava/awt/Component;)Ljavax/accessibility/AccessibleSelection;", ret);

@implementation ComboBoxAccessibility

// NSAccessibilityElement protocol methods
@@ -43,15 +49,21 @@ - (id)accessibilityValue {
JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject axContext = [self axContextWithEnv:env];
if (axContext == NULL) return nil;
jclass axContextClass = (*env)->GetObjectClass(env, axContext);
DECLARE_METHOD_RETURN(jm_getAccessibleSelection, axContextClass, "getAccessibleSelection", "(I)Ljavax/accessibility/Accessible;", nil);
jobject axSelectedChild = (*env)->CallObjectMethod(env, axContext, jm_getAccessibleSelection, 0);
GET_ACCESSIBLESELECTION_METHOD_RETURN(nil);
jobject axSelection = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleSelection, axContext, self->fComponent);
CHECK_EXCEPTION();
if (axSelection == NULL) {
return nil;
}
jclass axSelectionClass = (*env)->GetObjectClass(env, axSelection);
DECLARE_METHOD_RETURN(jm_getAccessibleSelection, axSelectionClass, "getAccessibleSelection", "(I)Ljavax/accessibility/Accessible;", nil);
jobject axSelectedChild = (*env)->CallObjectMethod(env, axSelection, jm_getAccessibleSelection, 0);
CHECK_EXCEPTION();
(*env)->DeleteLocalRef(env, axSelection);
(*env)->DeleteLocalRef(env, axContext);
if (axSelectedChild == NULL) {
return nil;
}
GET_CACCESSIBILITY_CLASS_RETURN(nil);
GET_ACCESSIBLENAME_METHOD_RETURN(nil);
jobject childName = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, sjm_getAccessibleName, axSelectedChild, fComponent);
CHECK_EXCEPTION();

1 comment on commit ddc81f2

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on ddc81f2 Nov 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.