Skip to content
Permalink
Browse files
8274383: JNI call of getAccessibleSelection on a wrong thread
Reviewed-by: kizune, ant
  • Loading branch information
savoptik authored and Anton Tarasov committed Sep 28, 2021
1 parent be40373 commit b36881fa3b3f37400d4f2c0bca3192d88179f2ff
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();

3 comments on commit b36881f

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on b36881f Sep 28, 2021

Choose a reason for hiding this comment

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

@savoptik
Copy link
Contributor Author

@savoptik savoptik commented on b36881f Nov 17, 2021

Choose a reason for hiding this comment

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

/backport jdk17u

@openjdk
Copy link

@openjdk openjdk bot commented on b36881f Nov 17, 2021

Choose a reason for hiding this comment

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

@savoptik @savoptik the backport was successfully created on the branch savoptik-backport-b36881fa in my personal fork of openjdk/jdk17u. To create a pull request with this backport targeting openjdk/jdk17u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

this pull request contains a backport of commit b36881fa from the openjdk/jdk repository.

The commit being backported was authored by Artem Semenov on 28 Sep 2021 and was reviewed by Alexander Zuev and Anton Tarasov.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u:

$ git fetch https://github.com/openjdk-bots/jdk17u savoptik-backport-b36881fa:savoptik-backport-b36881fa
$ git checkout savoptik-backport-b36881fa
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u savoptik-backport-b36881fa

Please sign in to comment.