8299412: JNI call of getAccessibleActionCount on a wrong thread

Reviewed-by: prr, serb
This commit is contained in:
Artem Semenov 2023-01-06 07:09:05 +00:00
parent 7845b0d7b4
commit 775da84a84
2 changed files with 10 additions and 5 deletions

View File

@ -519,6 +519,13 @@ class CAccessibility implements PropertyChangeListener {
}, c);
}
// This method is called from the native in CommonComponentAccessibility.m
private static int getAccessibleActionCount(final AccessibleAction aa, final Component c) {
if (aa == null) return 0;
return invokeAndWait(aa::getAccessibleActionCount, c);
}
public static boolean isEnabled(final Accessible a, final Component c) {
if (a == null) return false;

View File

@ -600,11 +600,9 @@ static jobject sAccessibilityClass = NULL;
jobject axAction = (*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getAccessibleAction, fAccessible, fComponent);
CHECK_EXCEPTION();
if (axAction != NULL) {
jclass jc_AccessibleAction = NULL;
GET_CLASS(jc_AccessibleAction, "javax/accessibility/AccessibleAction");
jmethodID jm_getAccessibleActionCount = NULL;
GET_METHOD(jm_getAccessibleActionCount, jc_AccessibleAction, "getAccessibleActionCount", "()I");
jint count = (*env)->CallIntMethod(env, axAction, jm_getAccessibleActionCount);
DECLARE_STATIC_METHOD(jm_getAccessibleActionCount, sjc_CAccessibility, "getAccessibleActionCount", "(Ljavax/accessibility/AccessibleAction;Ljava/awt/Component;)I");
jint count = (*env)->CallStaticIntMethod(env, sjc_CAccessibility, jm_getAccessibleActionCount, axAction, fComponent);
CHECK_EXCEPTION();
fActions = [[NSMutableDictionary alloc] initWithCapacity:count];
fActionSelectors = [[NSMutableArray alloc] initWithCapacity:count];
for (int i =0; i < count; i++) {