< prev index next >

src/jdk.accessibility/windows/native/libjavaaccessbridge/AccessBridgeJavaEntryPoints.cpp

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this

@@ -80,10 +80,26 @@
          jniEnv->ExceptionDescribe();                                                            \
          jniEnv->ExceptionClear();                                                               \
          return (returnVal);                                                                     \
      }
  
+ #define EXCEPTION_CHECK_WITH_RELEASE(situationDescription, returnVal, js, stringBytes)          \
+     if (exception = jniEnv->ExceptionOccurred()) {                                              \
+         PrintDebugString("[ERROR]: *** Exception occured while doing: %s - call to GetStringLength; returning %d", situationDescription, returnVal);   \
+         jniEnv->ExceptionDescribe();                                                            \
+         jniEnv->ExceptionClear();                                                               \
+         jniEnv->ReleaseStringChars(js, stringBytes);                                            \
+         return (returnVal);                                                                     \
+     }                                                                                           \
+     jniEnv->ReleaseStringChars(js, stringBytes);                                                \
+     if (exception = jniEnv->ExceptionOccurred()) {                                              \
+         PrintDebugString("[ERROR]: *** Exception occured while doing: %s - call to ReleaseStringChars; returning %d", situationDescription, returnVal);   \
+         jniEnv->ExceptionDescribe();                                                            \
+         jniEnv->ExceptionClear();                                                               \
+         return (returnVal);                                                                     \
+     }
+ 
  #define EXCEPTION_CHECK_VOID(situationDescription)                                              \
      if (exception = jniEnv->ExceptionOccurred()) {                                              \
          PrintDebugString("[ERROR]: *** Exception occured while doing: %s", situationDescription);   \
          jniEnv->ExceptionDescribe();                                                            \
          jniEnv->ExceptionClear();                                                               \

@@ -1213,13 +1229,11 @@
          {
              stringBytes = (const wchar_t *) jniEnv->GetStringChars (js, 0);
              EXCEPTION_CHECK("Getting AccessibleName - call to GetStringChars()", FALSE);
              wcsncpy(name, stringBytes, nameSize - 1);
              length = jniEnv->GetStringLength(js);
-             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleName - call to ReleaseStringChars()", FALSE);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleName", FALSE, js, stringBytes);
              jniEnv->CallVoidMethod (
                  accessBridgeObject,
                  decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE);
              wPrintDebugString(L"  Accessible Name = %ls", name);

@@ -1378,13 +1392,11 @@
                  EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringChars()", FALSE);
                  wcsncpy(test_attributes.fullAttributesString, stringBytes, (sizeof(test_attributes.fullAttributesString) / sizeof(wchar_t)));
                  length = jniEnv->GetStringLength(js);
                  test_attributes.fullAttributesString[length < (sizeof(test_attributes.fullAttributesString) / sizeof(wchar_t)) ?
                                                       length : (sizeof(test_attributes.fullAttributesString) / sizeof(wchar_t))-2] = (wchar_t) 0;
-                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringLength()", FALSE);
-                 jniEnv->ReleaseStringChars(js, stringBytes);
-                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to ReleaseStringChars()", FALSE);
+                 EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleAttributesAtIndex", FALSE, js, stringBytes);
                  jniEnv->CallVoidMethod(accessBridgeObject,
                                         decrementReferenceMethod, js);
                  EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallVoidMethod()", FALSE);
                  wPrintDebugString(L"[INFO]:  Accessible Text attributes = %ls", test_attributes.fullAttributesString);
                  jniEnv->DeleteLocalRef(js);

@@ -1733,15 +1745,13 @@
          if (js != (jstring) 0) {
              stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
              EXCEPTION_CHECK("Getting AccessibleName - call to GetStringChars()", FALSE);
              wcsncpy(info->name, stringBytes, (sizeof(info->name) / sizeof(wchar_t)));
              length = jniEnv->GetStringLength(js);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleName", FALSE, js, stringBytes);
              info->name[length < (sizeof(info->name) / sizeof(wchar_t)) ?
                         length : (sizeof(info->name) / sizeof(wchar_t))-2] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleName - call to ReleaseStringChars()", FALSE);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE);
              wPrintDebugString(L"[INFO]:   Accessible Name = %ls", info->name);
              jniEnv->DeleteLocalRef(js);

@@ -1765,15 +1775,13 @@
          if (js != (jstring) 0) {
              stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
              EXCEPTION_CHECK("Getting AccessibleName - call to GetStringChars()", FALSE);
              wcsncpy(info->description, stringBytes, (sizeof(info->description) / sizeof(wchar_t)));
              length = jniEnv->GetStringLength(js);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleName", FALSE, js, stringBytes);
              info->description[length < (sizeof(info->description) / sizeof(wchar_t)) ?
                                length : (sizeof(info->description) / sizeof(wchar_t))-2] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleName - call to ReleaseStringChars()", FALSE);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE);
              wPrintDebugString(L"[INFO]:   Accessible Description = %ls", info->description);
              jniEnv->DeleteLocalRef(js);

@@ -1797,15 +1805,13 @@
          if (js != (jstring) 0) {
              stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
              EXCEPTION_CHECK("Getting AccessibleRole - call to GetStringChars()", FALSE);
              wcsncpy(info->role, stringBytes, (sizeof(info->role) / sizeof(wchar_t)));
              length = jniEnv->GetStringLength(js);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleRole", FALSE, js, stringBytes);
              info->role[length < (sizeof(info->role) / sizeof(wchar_t)) ?
                         length : (sizeof(info->role) / sizeof(wchar_t))-2] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting AccessibleRole - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleRole - call to ReleaseStringChars()", FALSE);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting AccessibleRole - call to CallVoidMethod()", FALSE);
              wPrintDebugString(L"[INFO]:   Accessible Role = %ls", info->role);
              jniEnv->DeleteLocalRef(js);

@@ -1829,15 +1835,13 @@
          if (js != (jstring) 0) {
              stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
              EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to GetStringChars()", FALSE);
              wcsncpy(info->role_en_US, stringBytes, (sizeof(info->role_en_US) / sizeof(wchar_t)));
              length = jniEnv->GetStringLength(js);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleRole_en_US", FALSE, js, stringBytes);
              info->role_en_US[length < (sizeof(info->role_en_US) / sizeof(wchar_t)) ?
                               length : (sizeof(info->role_en_US) / sizeof(wchar_t))-2] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to ReleaseStringChars()", FALSE);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to CallVoidMethod()", FALSE);
              wPrintDebugString(L"[INFO]:   Accessible Role en_US = %ls", info->role_en_US);
              jniEnv->DeleteLocalRef(js);

@@ -1860,15 +1864,13 @@
          if (js != (jstring) 0) {
              stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
              EXCEPTION_CHECK("Getting AccessibleState - call to GetStringChars()", FALSE);
              wcsncpy(info->states, stringBytes, (sizeof(info->states) / sizeof(wchar_t)));
              length = jniEnv->GetStringLength(js);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleState", FALSE, js, stringBytes);
              info->states[length < (sizeof(info->states) / sizeof(wchar_t)) ?
                           length : (sizeof(info->states) / sizeof(wchar_t))-2] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting AccessibleState - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleState - call to ReleaseStringChars()", FALSE);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting AccessibleState - call to CallVoidMethod()", FALSE);
              wPrintDebugString(L"[INFO]:   Accessible States = %ls", info->states);
              jniEnv->DeleteLocalRef(js);

@@ -1891,15 +1893,13 @@
          if (js != (jstring) 0) {
              stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
              EXCEPTION_CHECK("Getting AccessibleState_en_US - call to GetStringChars()", FALSE);
              wcsncpy(info->states_en_US, stringBytes, (sizeof(info->states_en_US) / sizeof(wchar_t)));
              length = jniEnv->GetStringLength(js);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleState_en_US", FALSE, js, stringBytes);
              info->states_en_US[length < (sizeof(info->states_en_US) / sizeof(wchar_t)) ?
                                 length : (sizeof(info->states_en_US) / sizeof(wchar_t))-2] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to ReleaseStringChars()", FALSE);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting AccessibleState_en_US - call to CallVoidMethod()", FALSE);
              wPrintDebugString(L"[INFO]:   Accessible States en_US = %ls", info->states_en_US);
              jniEnv->DeleteLocalRef(js);

@@ -2807,15 +2807,13 @@
          if (js != (jstring) 0) {
              stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
              EXCEPTION_CHECK("Getting AccessibleRelation key - call to GetStringChars()", FALSE);
              wcsncpy(relationSet->relations[i].key, stringBytes, (sizeof(relationSet->relations[i].key ) / sizeof(wchar_t)));
              length = jniEnv->GetStringLength(js);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleRelation key", FALSE, js, stringBytes);
              relationSet->relations[i].key [length < (sizeof(relationSet->relations[i].key ) / sizeof(wchar_t)) ?
                                             length : (sizeof(relationSet->relations[i].key ) / sizeof(wchar_t))-2] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting AccessibleRelation key - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleRelation key - call to ReleaseStringChars()", FALSE);
              // jniEnv->CallVoidMethod(accessBridgeObject,
              //                        decrementReferenceMethod, js);
              //EXCEPTION_CHECK("Getting AccessibleRelation key - call to CallVoidMethod()", FALSE);
              PrintDebugString("[INFO]: ##### AccessibleRelation key = %ls", relationSet->relations[i].key );
              jniEnv->DeleteLocalRef(js);

@@ -2913,13 +2911,11 @@
              length = jniEnv->GetStringLength(js);
              if (length >= (sizeof(hypertext->links[i].text) / sizeof(wchar_t))) {
                  length = (sizeof(hypertext->links[i].text) / sizeof(wchar_t)) - 2;
              }
              hypertext->links[i].text[length] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to ReleaseStringChars()", FALSE);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleHyperlink text", FALSE, js, stringBytes);
              // jniEnv->CallVoidMethod(accessBridgeObject,
              //                                     decrementReferenceMethod, js);
              //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE);
              PrintDebugString("[INFO]: ##### AccessibleHyperlink text = %ls", hypertext->links[i].text );
              jniEnv->DeleteLocalRef(js);

@@ -3050,13 +3046,11 @@
              length = jniEnv->GetStringLength(js);
              if (length >= (sizeof(hypertext->links[bufIndex].text) / sizeof(wchar_t))) {
                  length = (sizeof(hypertext->links[bufIndex].text) / sizeof(wchar_t)) - 2;
              }
              hypertext->links[bufIndex].text[length] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to ReleaseStringChars()", FALSE);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleHyperlink text", FALSE, js, stringBytes);
              // jniEnv->CallVoidMethod(accessBridgeObject,
              //                        decrementReferenceMethod, js);
              //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE);
              PrintDebugString("[INFO]: ##### AccessibleHyperlink text = %ls", hypertext->links[bufIndex].text );
              jniEnv->DeleteLocalRef(js);

@@ -3169,13 +3163,11 @@
          length = jniEnv->GetStringLength(js);
          if (length >= (sizeof(info->text) / sizeof(wchar_t))) {
              length = (sizeof(info->text) / sizeof(wchar_t)) - 2;
          }
          info->text[length] = (wchar_t) 0;
-         EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringLength()", FALSE);
-         jniEnv->ReleaseStringChars(js, stringBytes);
-         EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to ReleaseStringChars()", FALSE);
+         EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleHyperlink text", FALSE, js, stringBytes);
          // jniEnv->CallVoidMethod(accessBridgeObject,
          //                        decrementReferenceMethod, js);
          //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE);
          PrintDebugString("[INFO]: ##### AccessibleHyperlink text = %ls", info->text );
          jniEnv->DeleteLocalRef(js);

@@ -3298,13 +3290,11 @@
              length = jniEnv->GetStringLength(js);
              if (length >= (sizeof(icons->iconInfo[i].description) / sizeof(wchar_t))) {
                  length = (sizeof(icons->iconInfo[i].description) / sizeof(wchar_t)) - 2;
              }
              icons->iconInfo[i].description[length] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting AccessibleIcon description - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleIcon description - call to ReleaseStringChars()", FALSE);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleIcon description", FALSE, js, stringBytes);
              // jniEnv->CallVoidMethod(accessBridgeObject,
              //                        decrementReferenceMethod, js);
              //EXCEPTION_CHECK("Getting AccessibleIcon description - call to CallVoidMethod()", FALSE);
              PrintDebugString("[INFO]: ##### AccessibleIcon description = %ls", icons->iconInfo[i].description );
              jniEnv->DeleteLocalRef(js);

@@ -3377,13 +3367,11 @@
              length = jniEnv->GetStringLength(js);
              if (length >= (sizeof(actions->actionInfo[i].name ) / sizeof(wchar_t))) {
                  length = (sizeof(actions->actionInfo[i].name ) / sizeof(wchar_t)) - 2;
              }
              actions->actionInfo[i].name [length] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting AccessibleAction name  - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleAction name  - call to ReleaseStringChars()", FALSE);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleAction name", FALSE, js, stringBytes);
              // jniEnv->CallVoidMethod(accessBridgeObject,
              //                        decrementReferenceMethod, js);
              //EXCEPTION_CHECK("Getting AccessibleAction name  - call to CallVoidMethod()", FALSE);
              PrintDebugString("[INFO]: ##### AccessibleAction name  = %ls", actions->actionInfo[i].name  );
              jniEnv->DeleteLocalRef(js);

@@ -3559,13 +3547,11 @@
              EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to GetStringChars()", FALSE);
              wcsncpy(textItems->word, stringBytes, (sizeof(textItems->word) / sizeof(wchar_t)));
              length = jniEnv->GetStringLength(js);
              textItems->word[length < (sizeof(textItems->word) / sizeof(wchar_t)) ?
                              length : (sizeof(textItems->word) / sizeof(wchar_t))-2] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to ReleaseStringChars()", FALSE);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleWordAtIndex", FALSE, js, stringBytes);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to CallVoidMethod()", FALSE);
              wPrintDebugString(L"[INFO]:   Accessible Text word = %ls", textItems->word);
              jniEnv->DeleteLocalRef(js);

@@ -3595,13 +3581,11 @@
              if (length < sizeof(textItems->sentence) / sizeof(wchar_t)) {
                  textItems->sentence[length] = (wchar_t) 0;
              } else {
                  textItems->sentence[(sizeof(textItems->sentence) / sizeof(wchar_t))-2] = (wchar_t) 0;
              }
-             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to ReleaseStringChars()", FALSE);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleSentenceAtIndex", FALSE, js, stringBytes);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to CallVoidMethod()", FALSE);
              wPrintDebugString(L"[INFO]:   Accessible Text sentence = %ls", textItems->sentence);
              jniEnv->DeleteLocalRef(js);

@@ -3671,13 +3655,11 @@
              EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to GetStringChars()", FALSE);
              wcsncpy(selectionInfo->selectedText, stringBytes, (sizeof(selectionInfo->selectedText) / sizeof(wchar_t)));
              length = jniEnv->GetStringLength(js);
              selectionInfo->selectedText[length < (sizeof(selectionInfo->selectedText) / sizeof(wchar_t)) ?
                                          length : (sizeof(selectionInfo->selectedText) / sizeof(wchar_t))-2] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to ReleaseStringChars()", FALSE);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleTextSelectedText", FALSE, js, stringBytes);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to CallVoidMethod()", FALSE);
              PrintDebugString("[INFO]:   Accessible's selected text = %s", selectionInfo->selectedText);
              jniEnv->DeleteLocalRef(js);

@@ -3888,13 +3870,11 @@
              EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to GetStringChars()", FALSE);
              wcsncpy(attributes->backgroundColor, stringBytes, (sizeof(attributes->backgroundColor) / sizeof(wchar_t)));
              length = jniEnv->GetStringLength(js);
              attributes->backgroundColor[length < (sizeof(attributes->backgroundColor) / sizeof(wchar_t)) ?
                                          length : (sizeof(attributes->backgroundColor) / sizeof(wchar_t))-2] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to ReleaseStringChars()", FALSE);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting BackgroundColorFromAttributeSet", FALSE, js, stringBytes);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
              wPrintDebugString(L"[INFO]:   AttributeSet's background color = %ls", attributes->backgroundColor);
              jniEnv->DeleteLocalRef(js);

@@ -3925,13 +3905,11 @@
              EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to GetStringChars()", FALSE);
              wcsncpy(attributes->foregroundColor, stringBytes, (sizeof(attributes->foregroundColor) / sizeof(wchar_t)));
              length = jniEnv->GetStringLength(js);
              attributes->foregroundColor[length < (sizeof(attributes->foregroundColor) / sizeof(wchar_t)) ?
                                          length : (sizeof(attributes->foregroundColor) / sizeof(wchar_t))-2] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to ReleaseStringChars()", FALSE);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting ForegroundColorFromAttributeSet", FALSE, js, stringBytes);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
              wPrintDebugString(L"[INFO]:   AttributeSet's foreground color = %ls", attributes->foregroundColor);
              jniEnv->DeleteLocalRef(js);

@@ -3962,13 +3940,11 @@
              EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to GetStringChars()", FALSE);
              wcsncpy(attributes->fontFamily, stringBytes, (sizeof(attributes->fontFamily) / sizeof(wchar_t)));
              length = jniEnv->GetStringLength(js);
              attributes->fontFamily[length < (sizeof(attributes->fontFamily) / sizeof(wchar_t)) ?
                                     length : (sizeof(attributes->fontFamily) / sizeof(wchar_t))-2] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to ReleaseStringChars()", FALSE);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting FontFamilyFromAttributeSet", FALSE, js, stringBytes);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to CallVoidMethod()", FALSE);
              wPrintDebugString(L"[INFO]:   AttributeSet's fontFamily = %ls", attributes->fontFamily);
              jniEnv->DeleteLocalRef(js);

@@ -4168,13 +4144,11 @@
              EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringChars()", FALSE);
              wcsncpy(attributes->fullAttributesString, stringBytes, (sizeof(attributes->fullAttributesString) / sizeof(wchar_t)));
              length = jniEnv->GetStringLength(js);
              attributes->fullAttributesString[length < (sizeof(attributes->fullAttributesString) / sizeof(wchar_t)) ?
                                               length : (sizeof(attributes->fullAttributesString) / sizeof(wchar_t))-2] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to ReleaseStringChars()", FALSE);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleAttributesAtIndex", FALSE, js, stringBytes);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallVoidMethod()", FALSE);
              wPrintDebugString(L"[INFO]:   Accessible Text attributes = %ls", attributes->fullAttributesString);
              jniEnv->DeleteLocalRef(js);

@@ -4411,13 +4385,11 @@
              wcsncpy(text, stringBytes, len);
              length = jniEnv->GetStringLength(js);
              PrintDebugString("[INFO]:  Accessible Text stringBytes length = %d", length);
              text[length < len ? length : len - 2] = (wchar_t) 0;
              wPrintDebugString(L"[INFO]:   Accessible Text 'text' after null termination = %ls", text);
-             EXCEPTION_CHECK("Getting AccessibleTextRange - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting AccessibleTextRange - call to ReleaseStringChars()", FALSE);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleTextRange", FALSE, js, stringBytes);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting AccessibleTextRange - call to CallVoidMethod()", FALSE);
              wPrintDebugString(L"[INFO]:   Accessible Text range = %ls", text);
              jniEnv->DeleteLocalRef(js);

@@ -4456,13 +4428,11 @@
              stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
              EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to GetStringChars()", FALSE);
              wcsncpy(value, stringBytes, len);
              length = jniEnv->GetStringLength(js);
              value[length < len ? length : len - 2] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to ReleaseStringChars()", FALSE);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting CurrentAccessibleValue", FALSE, js, stringBytes);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to CallVoidMethod()", FALSE);
              PrintDebugString("[INFO]:   current Accessible Value = %s", value);
              jniEnv->DeleteLocalRef(js);

@@ -4499,13 +4469,11 @@
              stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
              EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to GetStringChars()", FALSE);
              wcsncpy(value, stringBytes, len);
              length = jniEnv->GetStringLength(js);
              value[length < len ? length : len - 2] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to ReleaseStringChars()", FALSE);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting MaximumAccessibleValue", FALSE, js, stringBytes);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to CallVoidMethod()", FALSE);
              PrintDebugString("[INFO]:   maximum Accessible Value = %s", value);
              jniEnv->DeleteLocalRef(js);

@@ -4542,13 +4510,11 @@
              stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
              EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to GetStringChars()", FALSE);
              wcsncpy(value, stringBytes, len);
              length = jniEnv->GetStringLength(js);
              value[length < len ? length : len - 2] = (wchar_t) 0;
-             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to GetStringLength()", FALSE);
-             jniEnv->ReleaseStringChars(js, stringBytes);
-             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to ReleaseStringChars()", FALSE);
+             EXCEPTION_CHECK_WITH_RELEASE("Getting MinimumAccessibleValue", FALSE, js, stringBytes);
              jniEnv->CallVoidMethod(accessBridgeObject,
                                     decrementReferenceMethod, js);
              EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to CallVoidMethod()", FALSE);
              PrintDebugString("[INFO]:   mimimum Accessible Value = %s", value);
              jniEnv->DeleteLocalRef(js);
< prev index next >