1 /*
   2  * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /*
  27  * A class to manage JNI calls into AccessBridge.java
  28  */
  29 
  30 #include "AccessBridgeJavaEntryPoints.h"
  31 #include "AccessBridgeDebug.h"
  32 
  33 
  34 
  35 /**
  36  * Initialize the AccessBridgeJavaEntryPoints class
  37  *
  38  */
  39 AccessBridgeJavaEntryPoints::AccessBridgeJavaEntryPoints(JNIEnv *jniEnvironment,
  40                                                          jobject bridgeObject) {
  41     jniEnv = jniEnvironment;
  42     accessBridgeObject = (jobject)bridgeObject;
  43     PrintDebugString("[INFO]: AccessBridgeJavaEntryPoints(%p, %p) called", jniEnv, accessBridgeObject);
  44 }
  45 
  46 
  47 /**
  48  * Destructor
  49  *
  50  */
  51 AccessBridgeJavaEntryPoints::~AccessBridgeJavaEntryPoints() {
  52 }
  53 
  54 // -----------------------------------
  55 
  56 #define FIND_CLASS(classRef, className) \
  57     localClassRef = jniEnv->FindClass(className); \
  58     if (localClassRef == (jclass) 0) { \
  59         PrintDebugString("[ERROR]:  FindClass(%s) failed! -> jniEnv = %p", className, jniEnv); \
  60         return FALSE; \
  61     } \
  62     classRef = (jclass) jniEnv->NewGlobalRef(localClassRef); \
  63     jniEnv->DeleteLocalRef(localClassRef); \
  64     if (classRef == (jclass) 0) { \
  65         PrintDebugString("[ERROR]: FindClass(%s) failed! ->  (ran out of RAM)", className); \
  66         return FALSE; \
  67     }
  68 
  69 
  70 #define FIND_METHOD(methodID, classRef, methodString, methodSignature); \
  71     methodID = jniEnv->GetMethodID(classRef, methodString,  methodSignature); \
  72     if (methodID == (jmethodID) 0) { \
  73         PrintDebugString("[ERROR]: GetMethodID(%s) failed! -> jniEnv = %p; classRef = %p", methodString, jniEnv, classRef); \
  74         return FALSE; \
  75     }
  76 
  77 #define EXCEPTION_CHECK(situationDescription, returnVal)                                        \
  78     if (exception = jniEnv->ExceptionOccurred()) {                                              \
  79         PrintDebugString("[ERROR]: *** Exception occured while doing: %s; returning %d", situationDescription, returnVal);   \
  80         jniEnv->ExceptionDescribe();                                                            \
  81         jniEnv->ExceptionClear();                                                               \
  82         return (returnVal);                                                                     \
  83     }
  84 
  85 #define EXCEPTION_CHECK_WITH_RELEASE(situationDescription, returnVal, js, stringBytes)          \
  86     if (exception = jniEnv->ExceptionOccurred()) {                                              \
  87         PrintDebugString("[ERROR]: *** Exception occured while doing: %s - call to GetStringLength; returning %d", situationDescription, returnVal);   \
  88         jniEnv->ExceptionDescribe();                                                            \
  89         jniEnv->ExceptionClear();                                                               \
  90         jniEnv->ReleaseStringChars(js, stringBytes);                                            \
  91         return (returnVal);                                                                     \
  92     }                                                                                           \
  93     jniEnv->ReleaseStringChars(js, stringBytes);                                                \
  94     if (exception = jniEnv->ExceptionOccurred()) {                                              \
  95         PrintDebugString("[ERROR]: *** Exception occured while doing: %s - call to ReleaseStringChars; returning %d", situationDescription, returnVal);   \
  96         jniEnv->ExceptionDescribe();                                                            \
  97         jniEnv->ExceptionClear();                                                               \
  98         return (returnVal);                                                                     \
  99     }
 100 
 101 #define EXCEPTION_CHECK_VOID(situationDescription)                                              \
 102     if (exception = jniEnv->ExceptionOccurred()) {                                              \
 103         PrintDebugString("[ERROR]: *** Exception occured while doing: %s", situationDescription);   \
 104         jniEnv->ExceptionDescribe();                                                            \
 105         jniEnv->ExceptionClear();                                                               \
 106         return;                                                                                 \
 107     }
 108 
 109 /**
 110  * Make all of the getClass() & getMethod() calls
 111  *
 112  */
 113 BOOL
 114 AccessBridgeJavaEntryPoints::BuildJavaEntryPoints() {
 115     jclass localClassRef;
 116 
 117     PrintDebugString("[INFO]: Calling BuildJavaEntryPoints():");
 118 
 119     FIND_CLASS(bridgeClass, "com/sun/java/accessibility/internal/AccessBridge");
 120 
 121     // ------- general methods
 122 
 123     // GetMethodID(decrementReference)
 124     FIND_METHOD(decrementReferenceMethod, bridgeClass,
 125                 "decrementReference",
 126                 "(Ljava/lang/Object;)V");
 127 
 128     // GetMethodID(getJavaVersionPropertyMethod)
 129     FIND_METHOD(getJavaVersionPropertyMethod, bridgeClass,
 130                 "getJavaVersionProperty",
 131                 "()Ljava/lang/String;");
 132 
 133     // ------- Window methods
 134 
 135     // GetMethodID(isJavaWindow)
 136     FIND_METHOD(isJavaWindowMethod, bridgeClass,
 137                 "isJavaWindow",
 138                 "(I)Z");
 139 
 140     // GetMethodID(getAccessibleContextFromHWND)
 141     FIND_METHOD(getAccessibleContextFromHWNDMethod, bridgeClass,
 142                 "getContextFromNativeWindowHandle",
 143                 "(I)Ljavax/accessibility/AccessibleContext;");
 144 
 145     // GetMethodID(getHWNDFromAccessibleContext)
 146     FIND_METHOD(getHWNDFromAccessibleContextMethod, bridgeClass,
 147                 "getNativeWindowHandleFromContext",
 148                 "(Ljavax/accessibility/AccessibleContext;)I");
 149 
 150     // GetMethodID(getAccessibleParentFromContext)
 151     FIND_METHOD(getAccessibleParentFromContextMethod, bridgeClass,
 152                 "getAccessibleParentFromContext",
 153                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleContext;");
 154 
 155     // ===== utility methods ===== */
 156 
 157     // GetMethodID(setTextContents)
 158     FIND_METHOD(setTextContentsMethod, bridgeClass,
 159                 "setTextContents",
 160                 "(Ljavax/accessibility/AccessibleContext;Ljava/lang/String;)Z");
 161 
 162     // GetMethodID(getParentWithRole)
 163     FIND_METHOD(getParentWithRoleMethod, bridgeClass,
 164                 "getParentWithRole",
 165                 "(Ljavax/accessibility/AccessibleContext;Ljava/lang/String;)Ljavax/accessibility/AccessibleContext;");
 166 
 167     // GetMethodID(getTopLevelObject)
 168     FIND_METHOD(getTopLevelObjectMethod, bridgeClass,
 169                 "getTopLevelObject",
 170                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleContext;");
 171 
 172     // GetMethodID(getParentWithRoleElseRoot)
 173     FIND_METHOD(getParentWithRoleElseRootMethod, bridgeClass,
 174                 "getParentWithRoleElseRoot",
 175                 "(Ljavax/accessibility/AccessibleContext;Ljava/lang/String;)Ljavax/accessibility/AccessibleContext;");
 176 
 177     // GetMethodID(getObjectDepth)
 178     FIND_METHOD(getObjectDepthMethod, bridgeClass,
 179                 "getObjectDepth",
 180                 "(Ljavax/accessibility/AccessibleContext;)I");
 181 
 182     // GetMethodID(getActiveDescendent)
 183     FIND_METHOD(getActiveDescendentMethod, bridgeClass,
 184                 "getActiveDescendent",
 185                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleContext;");
 186 
 187     // ------- AccessibleContext methods
 188 
 189     // GetMethodID(getAccessibleContextAt)
 190     FIND_METHOD(getAccessibleContextAtMethod, bridgeClass,
 191                 "getAccessibleContextAt",
 192                 "(IILjavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleContext;");
 193 
 194     // GetMethodID(getAccessibleContextWithFocus)
 195     FIND_METHOD(getAccessibleContextWithFocusMethod, bridgeClass,
 196                 "getAccessibleContextWithFocus",
 197                 "()Ljavax/accessibility/AccessibleContext;");
 198 
 199     // GetMethodID(getAccessibleNameFromContext)
 200     FIND_METHOD(getAccessibleNameFromContextMethod, bridgeClass,
 201                 "getAccessibleNameFromContext",
 202                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 203 
 204     // GetMethodID(getAccessibleDescriptionFromContext)
 205     FIND_METHOD(getAccessibleDescriptionFromContextMethod, bridgeClass,
 206                 "getAccessibleDescriptionFromContext",
 207                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 208 
 209     // GetMethodID(getAccessibleRoleStringFromContext)
 210     FIND_METHOD(getAccessibleRoleStringFromContextMethod, bridgeClass,
 211                 "getAccessibleRoleStringFromContext",
 212                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 213 
 214     // GetMethodID(getAccessibleRoleStringFromContext_en_US)
 215     FIND_METHOD(getAccessibleRoleStringFromContext_en_USMethod, bridgeClass,
 216                 "getAccessibleRoleStringFromContext_en_US",
 217                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 218 
 219     // GetMethodID(getAccessibleStatesStringFromContext)
 220     FIND_METHOD(getAccessibleStatesStringFromContextMethod, bridgeClass,
 221                 "getAccessibleStatesStringFromContext",
 222                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 223 
 224     // GetMethodID(getAccessibleStatesStringFromContext_en_US)
 225     FIND_METHOD(getAccessibleStatesStringFromContext_en_USMethod, bridgeClass,
 226                 "getAccessibleStatesStringFromContext_en_US",
 227                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 228 
 229     // GetMethodID(getAccessibleParentFromContext)
 230     FIND_METHOD(getAccessibleParentFromContextMethod, bridgeClass,
 231                 "getAccessibleParentFromContext",
 232                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleContext;");
 233 
 234     // GetMethodID(getAccessibleIndexInParentFromContext)
 235     FIND_METHOD(getAccessibleIndexInParentFromContextMethod, bridgeClass,
 236                 "getAccessibleIndexInParentFromContext",
 237                 "(Ljavax/accessibility/AccessibleContext;)I");
 238 
 239     // GetMethodID(getAccessibleChildrenCountFromContext)
 240     FIND_METHOD(getAccessibleChildrenCountFromContextMethod, bridgeClass,
 241                 "getAccessibleChildrenCountFromContext",
 242                 "(Ljavax/accessibility/AccessibleContext;)I");
 243 
 244     // GetMethodID(getAccessibleChildFromContext)
 245     FIND_METHOD(getAccessibleChildFromContextMethod, bridgeClass,
 246                 "getAccessibleChildFromContext",
 247                 "(Ljavax/accessibility/AccessibleContext;I)Ljavax/accessibility/AccessibleContext;");
 248 
 249     // GetMethodID(getAccessibleBoundsOnScreenFromContext)
 250     FIND_METHOD(getAccessibleBoundsOnScreenFromContextMethod, bridgeClass,
 251                 "getAccessibleBoundsOnScreenFromContext",
 252                 "(Ljavax/accessibility/AccessibleContext;)Ljava/awt/Rectangle;");
 253 
 254     // GetMethodID(getAccessibleXcoordFromContext)
 255     FIND_METHOD(getAccessibleXcoordFromContextMethod, bridgeClass,
 256                 "getAccessibleXcoordFromContext",
 257                 "(Ljavax/accessibility/AccessibleContext;)I");
 258 
 259     // GetMethodID(getAccessibleYcoordFromContext)
 260     FIND_METHOD(getAccessibleYcoordFromContextMethod, bridgeClass,
 261                 "getAccessibleYcoordFromContext",
 262                 "(Ljavax/accessibility/AccessibleContext;)I");
 263 
 264     // GetMethodID(getAccessibleHeightFromContext)
 265     FIND_METHOD(getAccessibleHeightFromContextMethod, bridgeClass,
 266                 "getAccessibleHeightFromContext",
 267                 "(Ljavax/accessibility/AccessibleContext;)I");
 268 
 269     // GetMethodID(getAccessibleWidthFromContext)
 270     FIND_METHOD(getAccessibleWidthFromContextMethod, bridgeClass,
 271                 "getAccessibleWidthFromContext",
 272                 "(Ljavax/accessibility/AccessibleContext;)I");
 273 
 274     // GetMethodID(getAccessibleComponentFromContext)
 275     FIND_METHOD(getAccessibleComponentFromContextMethod, bridgeClass,
 276                 "getAccessibleComponentFromContext",
 277                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleComponent;");
 278 
 279     // GetMethodID(getAccessibleActionFromContext)
 280     FIND_METHOD(getAccessibleActionFromContextMethod, bridgeClass,
 281                 "getAccessibleActionFromContext",
 282                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleAction;");
 283 
 284     // GetMethodID(getAccessibleSelectionFromContext)
 285     FIND_METHOD(getAccessibleSelectionFromContextMethod, bridgeClass,
 286                 "getAccessibleSelectionFromContext",
 287                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleSelection;");
 288 
 289     // GetMethodID(getAccessibleTextFromContext)
 290     FIND_METHOD(getAccessibleTextFromContextMethod, bridgeClass,
 291                 "getAccessibleTextFromContext",
 292                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleText;");
 293 
 294     // GetMethodID(getAccessibleValueFromContext)
 295     FIND_METHOD(getAccessibleValueFromContextMethod, bridgeClass,
 296                 "getAccessibleValueFromContext",
 297                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleValue;");
 298 
 299 
 300     // ------- begin AccessibleTable methods
 301 
 302     // GetMethodID(getAccessibleTableFromContext)
 303     FIND_METHOD(getAccessibleTableFromContextMethod, bridgeClass,
 304                 "getAccessibleTableFromContext",
 305                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleTable;");
 306 
 307     // GetMethodID(getContextFromAccessibleTable)
 308     FIND_METHOD(getContextFromAccessibleTableMethod, bridgeClass,
 309                 "getContextFromAccessibleTable",
 310                 "(Ljavax/accessibility/AccessibleTable;)Ljavax/accessibility/AccessibleContext;");
 311 
 312     // GetMethodID(getAccessibleTableRowHeader)
 313     FIND_METHOD(getAccessibleTableRowHeaderMethod, bridgeClass,
 314                 "getAccessibleTableRowHeader",
 315                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleTable;");
 316 
 317 
 318     // GetMethodID(getAccessibleTableColumnHeader)
 319     FIND_METHOD(getAccessibleTableColumnHeaderMethod, bridgeClass,
 320                 "getAccessibleTableColumnHeader",
 321                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleTable;");
 322 
 323 
 324     // GetMethodID(getAccessibleTableRowCount)
 325     FIND_METHOD(getAccessibleTableRowCountMethod, bridgeClass,
 326                 "getAccessibleTableRowCount",
 327                 "(Ljavax/accessibility/AccessibleContext;)I");
 328 
 329     // GetMethodID(getAccessibleTableColumnCount)
 330     FIND_METHOD(getAccessibleTableColumnCountMethod, bridgeClass,
 331                 "getAccessibleTableColumnCount",
 332                 "(Ljavax/accessibility/AccessibleContext;)I");
 333 
 334     // GetMethodID(getAccessibleTableCellAccessibleContext)
 335     FIND_METHOD(getAccessibleTableCellAccessibleContextMethod, bridgeClass,
 336                 "getAccessibleTableCellAccessibleContext",
 337                 "(Ljavax/accessibility/AccessibleTable;II)Ljavax/accessibility/AccessibleContext;");
 338 
 339     // GetMethodID(getAccessibleTableCellIndex)
 340     FIND_METHOD(getAccessibleTableCellIndexMethod, bridgeClass,
 341                 "getAccessibleTableCellIndex",
 342                 "(Ljavax/accessibility/AccessibleTable;II)I");
 343 
 344     // GetMethodID(getAccessibleTableCellRowExtent)
 345     FIND_METHOD(getAccessibleTableCellRowExtentMethod, bridgeClass,
 346                 "getAccessibleTableCellRowExtent",
 347                 "(Ljavax/accessibility/AccessibleTable;II)I");
 348 
 349     // GetMethodID(getAccessibleTableCellColumnExtent)
 350     FIND_METHOD(getAccessibleTableCellColumnExtentMethod, bridgeClass,
 351                 "getAccessibleTableCellColumnExtent",
 352                 "(Ljavax/accessibility/AccessibleTable;II)I");
 353 
 354     // GetMethodID(isAccessibleTableCellSelected)
 355     FIND_METHOD(isAccessibleTableCellSelectedMethod, bridgeClass,
 356                 "isAccessibleTableCellSelected",
 357                 "(Ljavax/accessibility/AccessibleTable;II)Z");
 358 
 359     // GetMethodID(getAccessibleTableRowHeaderRowCount)
 360     FIND_METHOD(getAccessibleTableRowHeaderRowCountMethod, bridgeClass,
 361                 "getAccessibleTableRowHeaderRowCount",
 362                 "(Ljavax/accessibility/AccessibleContext;)I");
 363 
 364     // GetMethodID(getAccessibleTableColumnHeaderRowCount)
 365     FIND_METHOD(getAccessibleTableColumnHeaderRowCountMethod, bridgeClass,
 366                 "getAccessibleTableColumnHeaderRowCount",
 367                 "(Ljavax/accessibility/AccessibleContext;)I");
 368 
 369     // GetMethodID(getAccessibleTableRowHeaderColumnCount)
 370     FIND_METHOD(getAccessibleTableRowHeaderColumnCountMethod, bridgeClass,
 371                 "getAccessibleTableRowHeaderColumnCount",
 372                 "(Ljavax/accessibility/AccessibleContext;)I");
 373 
 374     // GetMethodID(getAccessibleTableColumnHeaderColumnCount)
 375     FIND_METHOD(getAccessibleTableColumnHeaderColumnCountMethod, bridgeClass,
 376                 "getAccessibleTableColumnHeaderColumnCount",
 377                 "(Ljavax/accessibility/AccessibleContext;)I");
 378 
 379     // GetMethodID(getAccessibleTableRowDescription)
 380     FIND_METHOD(getAccessibleTableRowDescriptionMethod, bridgeClass,
 381                 "getAccessibleTableRowDescription",
 382                 "(Ljavax/accessibility/AccessibleTable;I)Ljavax/accessibility/AccessibleContext;");
 383 
 384     // GetMethodID(getAccessibleTableColumnDescription)
 385     FIND_METHOD(getAccessibleTableColumnDescriptionMethod, bridgeClass,
 386                 "getAccessibleTableColumnDescription",
 387                 "(Ljavax/accessibility/AccessibleTable;I)Ljavax/accessibility/AccessibleContext;");
 388 
 389     // GetMethodID(getAccessibleTableRowSelectionCount)
 390     FIND_METHOD(getAccessibleTableRowSelectionCountMethod, bridgeClass,
 391                 "getAccessibleTableRowSelectionCount",
 392                 "(Ljavax/accessibility/AccessibleTable;)I");
 393 
 394     // GetMethodID(isAccessibleTableRowSelected)
 395     FIND_METHOD(isAccessibleTableRowSelectedMethod, bridgeClass,
 396                 "isAccessibleTableRowSelected",
 397                 "(Ljavax/accessibility/AccessibleTable;I)Z");
 398 
 399     // GetMethodID(getAccessibleTableRowSelections)
 400     FIND_METHOD(getAccessibleTableRowSelectionsMethod, bridgeClass,
 401                 "getAccessibleTableRowSelections",
 402                 "(Ljavax/accessibility/AccessibleTable;I)I");
 403 
 404     // GetMethodID(getAccessibleTableColumnSelectionCount)
 405     FIND_METHOD(getAccessibleTableColumnSelectionCountMethod, bridgeClass,
 406                 "getAccessibleTableColumnSelectionCount",
 407                 "(Ljavax/accessibility/AccessibleTable;)I");
 408 
 409     // GetMethodID(isAccessibleTableColumnSelected)
 410     FIND_METHOD(isAccessibleTableColumnSelectedMethod, bridgeClass,
 411                 "isAccessibleTableColumnSelected",
 412                 "(Ljavax/accessibility/AccessibleTable;I)Z");
 413 
 414     // GetMethodID(getAccessibleTableColumnSelections)
 415     FIND_METHOD(getAccessibleTableColumnSelectionsMethod, bridgeClass,
 416                 "getAccessibleTableColumnSelections",
 417                 "(Ljavax/accessibility/AccessibleTable;I)I");
 418 
 419     // GetMethodID(getAccessibleTableRow)
 420     FIND_METHOD(getAccessibleTableRowMethod, bridgeClass,
 421                 "getAccessibleTableRow",
 422                 "(Ljavax/accessibility/AccessibleTable;I)I");
 423 
 424     // GetMethodID(getAccessibleTableColumn)
 425     FIND_METHOD(getAccessibleTableColumnMethod, bridgeClass,
 426                 "getAccessibleTableColumn",
 427                 "(Ljavax/accessibility/AccessibleTable;I)I");
 428 
 429     // GetMethodID(getAccessibleTableIndex)
 430     FIND_METHOD(getAccessibleTableIndexMethod, bridgeClass,
 431                 "getAccessibleTableIndex",
 432                 "(Ljavax/accessibility/AccessibleTable;II)I");
 433 
 434     /* ------- end AccessibleTable methods */
 435 
 436     /* start AccessibleRelationSet methods ----- */
 437 
 438     // GetMethodID(getAccessibleRelationCount)
 439     FIND_METHOD(getAccessibleRelationCountMethod, bridgeClass,
 440                 "getAccessibleRelationCount",
 441                 "(Ljavax/accessibility/AccessibleContext;)I");
 442 
 443     // GetMethodID(getAccessibleRelationKey)
 444     FIND_METHOD(getAccessibleRelationKeyMethod, bridgeClass,
 445                 "getAccessibleRelationKey",
 446                 "(Ljavax/accessibility/AccessibleContext;I)Ljava/lang/String;");
 447 
 448     // GetMethodID(getAccessibleRelationTargetCount)
 449     FIND_METHOD(getAccessibleRelationTargetCountMethod, bridgeClass,
 450                 "getAccessibleRelationTargetCount",
 451                 "(Ljavax/accessibility/AccessibleContext;I)I");
 452 
 453     // GetMethodID(getAccessibleRelationTarget)
 454     FIND_METHOD(getAccessibleRelationTargetMethod, bridgeClass,
 455                 "getAccessibleRelationTarget",
 456                 "(Ljavax/accessibility/AccessibleContext;II)Ljavax/accessibility/AccessibleContext;");
 457 
 458 
 459     // ------- AccessibleHypertext methods
 460 
 461     // GetMethodID(getAccessibleHypertext)
 462     FIND_METHOD(getAccessibleHypertextMethod, bridgeClass,
 463                 "getAccessibleHypertext",
 464                 "(Ljavax/accessibility/AccessibleContext;)Ljavax/accessibility/AccessibleHypertext;");
 465 
 466     // GetMethodID(activateAccessibleHyperlink)
 467     FIND_METHOD(activateAccessibleHyperlinkMethod, bridgeClass,
 468                 "activateAccessibleHyperlink",
 469                 "(Ljavax/accessibility/AccessibleContext;Ljavax/accessibility/AccessibleHyperlink;)Z");
 470 
 471     // GetMethodID(getAccessibleHyperlinkCount)
 472     FIND_METHOD(getAccessibleHyperlinkCountMethod, bridgeClass,
 473                 "getAccessibleHyperlinkCount",
 474                 "(Ljavax/accessibility/AccessibleContext;)I");
 475 
 476     // GetMethodID(getAccessibleHyperlink)
 477     FIND_METHOD(getAccessibleHyperlinkMethod, bridgeClass,
 478                 "getAccessibleHyperlink",
 479                 "(Ljavax/accessibility/AccessibleHypertext;I)Ljavax/accessibility/AccessibleHyperlink;");
 480 
 481     // GetMethodID(getAccessibleHyperlinkText)
 482     FIND_METHOD(getAccessibleHyperlinkTextMethod, bridgeClass,
 483                 "getAccessibleHyperlinkText",
 484                 "(Ljavax/accessibility/AccessibleHyperlink;)Ljava/lang/String;");
 485 
 486     // GetMethodID(getAccessibleHyperlinkURL)
 487     FIND_METHOD(getAccessibleHyperlinkURLMethod, bridgeClass,
 488                 "getAccessibleHyperlinkURL",
 489                 "(Ljavax/accessibility/AccessibleHyperlink;)Ljava/lang/String;");
 490 
 491     // GetMethodID(getAccessibleHyperlinkStartIndex)
 492     FIND_METHOD(getAccessibleHyperlinkStartIndexMethod, bridgeClass,
 493                 "getAccessibleHyperlinkStartIndex",
 494                 "(Ljavax/accessibility/AccessibleHyperlink;)I");
 495 
 496     // GetMethodID(getAccessibleHyperlinkEndIndex)
 497     FIND_METHOD(getAccessibleHyperlinkEndIndexMethod, bridgeClass,
 498                 "getAccessibleHyperlinkEndIndex",
 499                 "(Ljavax/accessibility/AccessibleHyperlink;)I");
 500 
 501     // GetMethodID(getAccessibleHypertextLinkIndex)
 502     FIND_METHOD(getAccessibleHypertextLinkIndexMethod, bridgeClass,
 503                 "getAccessibleHypertextLinkIndex",
 504                 "(Ljavax/accessibility/AccessibleHypertext;I)I");
 505 
 506     // Accessible KeyBinding, Icon and Action ====================
 507 
 508     // GetMethodID(getAccessibleKeyBindingsCount)
 509     FIND_METHOD(getAccessibleKeyBindingsCountMethod, bridgeClass,
 510                 "getAccessibleKeyBindingsCount",
 511                 "(Ljavax/accessibility/AccessibleContext;)I");
 512 
 513     // GetMethodID(getAccessibleKeyBindingChar)
 514     FIND_METHOD(getAccessibleKeyBindingCharMethod, bridgeClass,
 515                 "getAccessibleKeyBindingChar",
 516                 "(Ljavax/accessibility/AccessibleContext;I)C");
 517 
 518     // GetMethodID(getAccessibleKeyBindingModifiers)
 519     FIND_METHOD(getAccessibleKeyBindingModifiersMethod, bridgeClass,
 520                 "getAccessibleKeyBindingModifiers",
 521                 "(Ljavax/accessibility/AccessibleContext;I)I");
 522 
 523     // GetMethodID(getAccessibleIconsCount)
 524     FIND_METHOD(getAccessibleIconsCountMethod, bridgeClass,
 525                 "getAccessibleIconsCount",
 526                 "(Ljavax/accessibility/AccessibleContext;)I");
 527 
 528     // GetMethodID(getAccessibleIconDescription)
 529     FIND_METHOD(getAccessibleIconDescriptionMethod, bridgeClass,
 530                 "getAccessibleIconDescription",
 531                 "(Ljavax/accessibility/AccessibleContext;I)Ljava/lang/String;");
 532 
 533     // GetMethodID(getAccessibleIconHeight)
 534     FIND_METHOD(getAccessibleIconHeightMethod, bridgeClass,
 535                 "getAccessibleIconHeight",
 536                 "(Ljavax/accessibility/AccessibleContext;I)I");
 537 
 538     // GetMethodID(getAccessibleIconWidth)
 539     FIND_METHOD(getAccessibleIconWidthMethod, bridgeClass,
 540                 "getAccessibleIconWidth",
 541                 "(Ljavax/accessibility/AccessibleContext;I)I");
 542 
 543     // GetMethodID(getAccessibleActionsCount)
 544     FIND_METHOD(getAccessibleActionsCountMethod, bridgeClass,
 545                 "getAccessibleActionsCount",
 546                 "(Ljavax/accessibility/AccessibleContext;)I");
 547 
 548     // GetMethodID(getAccessibleActionName)
 549     FIND_METHOD(getAccessibleActionNameMethod, bridgeClass,
 550                 "getAccessibleActionName",
 551                 "(Ljavax/accessibility/AccessibleContext;I)Ljava/lang/String;");
 552 
 553     // GetMethodID(doAccessibleActions)
 554     FIND_METHOD(doAccessibleActionsMethod, bridgeClass,
 555                 "doAccessibleActions",
 556                 "(Ljavax/accessibility/AccessibleContext;Ljava/lang/String;)Z");
 557 
 558     // ------- AccessibleText methods
 559 
 560     // GetMethodID(getAccessibleCharCountFromContext)
 561     FIND_METHOD(getAccessibleCharCountFromContextMethod, bridgeClass,
 562                 "getAccessibleCharCountFromContext",
 563                 "(Ljavax/accessibility/AccessibleContext;)I");
 564 
 565     // GetMethodID(getAccessibleCaretPositionFromContext)
 566     FIND_METHOD(getAccessibleCaretPositionFromContextMethod, bridgeClass,
 567                 "getAccessibleCaretPositionFromContext",
 568                 "(Ljavax/accessibility/AccessibleContext;)I");
 569 
 570     // GetMethodID(getAccessibleIndexAtPointFromContext)
 571     FIND_METHOD(getAccessibleIndexAtPointFromContextMethod, bridgeClass,
 572                 "getAccessibleIndexAtPointFromContext",
 573                 "(Ljavax/accessibility/AccessibleContext;II)I");
 574 
 575     // GetMethodID(getAccessibleLetterAtIndexFromContext)
 576     FIND_METHOD(getAccessibleLetterAtIndexFromContextMethod, bridgeClass,
 577                 "getAccessibleLetterAtIndexFromContext",
 578                 "(Ljavax/accessibility/AccessibleContext;I)Ljava/lang/String;");
 579 
 580     // GetMethodID(getAccessibleWordAtIndexFromContext)
 581     FIND_METHOD(getAccessibleWordAtIndexFromContextMethod, bridgeClass,
 582                 "getAccessibleWordAtIndexFromContext",
 583                 "(Ljavax/accessibility/AccessibleContext;I)Ljava/lang/String;");
 584 
 585     // GetMethodID(getAccessibleSentenceAtIndexFromContext)
 586     FIND_METHOD(getAccessibleSentenceAtIndexFromContextMethod, bridgeClass,
 587                 "getAccessibleSentenceAtIndexFromContext",
 588                 "(Ljavax/accessibility/AccessibleContext;I)Ljava/lang/String;");
 589 
 590     // GetMethodID(getAccessibleTextSelectionStartFromContext)
 591     FIND_METHOD(getAccessibleTextSelectionStartFromContextMethod, bridgeClass,
 592                 "getAccessibleTextSelectionStartFromContext",
 593                 "(Ljavax/accessibility/AccessibleContext;)I");
 594 
 595     // GetMethodID(getAccessibleTextSelectionEndFromContext)
 596     FIND_METHOD(getAccessibleTextSelectionEndFromContextMethod, bridgeClass,
 597                 "getAccessibleTextSelectionEndFromContext",
 598                 "(Ljavax/accessibility/AccessibleContext;)I");
 599 
 600     // GetMethodID(getAccessibleTextSelectedTextFromContext)
 601     FIND_METHOD(getAccessibleTextSelectedTextFromContextMethod, bridgeClass,
 602                 "getAccessibleTextSelectedTextFromContext",
 603                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 604 
 605     // GetMethodID(getAccessibleAttributesAtIndexFromContext)
 606     FIND_METHOD(getAccessibleAttributesAtIndexFromContextMethod, bridgeClass,
 607                 "getAccessibleAttributesAtIndexFromContext",
 608                 "(Ljavax/accessibility/AccessibleContext;I)Ljava/lang/String;");
 609 
 610     // GetMethodID(getAccessibleAttributeSetAtIndexFromContext)
 611     FIND_METHOD(getAccessibleAttributeSetAtIndexFromContextMethod, bridgeClass,
 612                 "getAccessibleAttributeSetAtIndexFromContext",
 613                 "(Ljavax/accessibility/AccessibleContext;I)Ljavax/swing/text/AttributeSet;");
 614 
 615     // GetMethodID(getAccessibleTextRectAtIndexFromContext)
 616     FIND_METHOD(getAccessibleTextRectAtIndexFromContextMethod, bridgeClass,
 617                 "getAccessibleTextRectAtIndexFromContext",
 618                 "(Ljavax/accessibility/AccessibleContext;I)Ljava/awt/Rectangle;");
 619 
 620     // GetMethodID(getAccessibleXcoordTextRectAtIndexFromContext)
 621     FIND_METHOD(getAccessibleXcoordTextRectAtIndexFromContextMethod, bridgeClass,
 622                 "getAccessibleXcoordTextRectAtIndexFromContext",
 623                 "(Ljavax/accessibility/AccessibleContext;I)I");
 624 
 625     // GetMethodID(getAccessibleYcoordTextRectAtIndexFromContext)
 626     FIND_METHOD(getAccessibleYcoordTextRectAtIndexFromContextMethod, bridgeClass,
 627                 "getAccessibleYcoordTextRectAtIndexFromContext",
 628                 "(Ljavax/accessibility/AccessibleContext;I)I");
 629 
 630     // GetMethodID(getAccessibleHeightTextRectAtIndexFromContext)
 631     FIND_METHOD(getAccessibleHeightTextRectAtIndexFromContextMethod, bridgeClass,
 632                 "getAccessibleHeightTextRectAtIndexFromContext",
 633                 "(Ljavax/accessibility/AccessibleContext;I)I");
 634 
 635     // GetMethodID(getAccessibleWidthTextRectAtIndexFromContext)
 636     FIND_METHOD(getAccessibleWidthTextRectAtIndexFromContextMethod, bridgeClass,
 637                 "getAccessibleWidthTextRectAtIndexFromContext",
 638                 "(Ljavax/accessibility/AccessibleContext;I)I");
 639 
 640     // GetMethodID(getCaretLocationX)
 641     FIND_METHOD(getCaretLocationXMethod, bridgeClass,
 642                 "getCaretLocationX",
 643                 "(Ljavax/accessibility/AccessibleContext;)I");
 644 
 645     // GetMethodID(getCaretLocationY)
 646     FIND_METHOD(getCaretLocationYMethod, bridgeClass,
 647                 "getCaretLocationY",
 648                 "(Ljavax/accessibility/AccessibleContext;)I");
 649 
 650     // GetMethodID(getCaretLocationHeight)
 651     FIND_METHOD(getCaretLocationHeightMethod, bridgeClass,
 652                 "getCaretLocationHeight",
 653                 "(Ljavax/accessibility/AccessibleContext;)I");
 654 
 655     // GetMethodID(getCaretLocationWidth)
 656     FIND_METHOD(getCaretLocationWidthMethod, bridgeClass,
 657                 "getCaretLocationWidth",
 658                 "(Ljavax/accessibility/AccessibleContext;)I");
 659 
 660 
 661     // GetMethodID(getAccessibleTextLineLeftBoundsFromContextMethod)
 662     FIND_METHOD(getAccessibleTextLineLeftBoundsFromContextMethod, bridgeClass,
 663                 "getAccessibleTextLineLeftBoundsFromContext",
 664                 "(Ljavax/accessibility/AccessibleContext;I)I");
 665 
 666     // GetMethodID(getAccessibleTextLineRightBoundsFromContextMethod)
 667     FIND_METHOD(getAccessibleTextLineRightBoundsFromContextMethod, bridgeClass,
 668                 "getAccessibleTextLineRightBoundsFromContext",
 669                 "(Ljavax/accessibility/AccessibleContext;I)I");
 670 
 671     // GetMethodID(getAccessibleTextRangeFromContextMethod)
 672     FIND_METHOD(getAccessibleTextRangeFromContextMethod, bridgeClass,
 673                 "getAccessibleTextRangeFromContext",
 674                 "(Ljavax/accessibility/AccessibleContext;II)Ljava/lang/String;");
 675 
 676 
 677     // ------- AccessibleValue methods
 678 
 679     // GetMethodID(getCurrentAccessibleValueFromContext)
 680     FIND_METHOD(getCurrentAccessibleValueFromContextMethod, bridgeClass,
 681                 "getCurrentAccessibleValueFromContext",
 682                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 683 
 684     // GetMethodID(getMaximumAccessibleValueFromContext)
 685     FIND_METHOD(getMaximumAccessibleValueFromContextMethod, bridgeClass,
 686                 "getMaximumAccessibleValueFromContext",
 687                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 688 
 689     // GetMethodID(getMinimumAccessibleValueFromContext)
 690     FIND_METHOD(getMinimumAccessibleValueFromContextMethod, bridgeClass,
 691                 "getMinimumAccessibleValueFromContext",
 692                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 693 
 694 
 695     // ------- AccessibleSelection methods
 696 
 697     // GetMethodID(addAccessibleSelectionFromContext)
 698     FIND_METHOD(addAccessibleSelectionFromContextMethod, bridgeClass,
 699                 "addAccessibleSelectionFromContext",
 700                 "(Ljavax/accessibility/AccessibleContext;I)V");
 701 
 702     // GetMethodID(clearAccessibleSelectionFromContext)
 703     FIND_METHOD(clearAccessibleSelectionFromContextMethod, bridgeClass,
 704                 "clearAccessibleSelectionFromContext",
 705                 "(Ljavax/accessibility/AccessibleContext;)V");
 706 
 707     // GetMethodID(getAccessibleSelectionFromContext)
 708     FIND_METHOD(getAccessibleSelectionContextFromContextMethod, bridgeClass,
 709                 "getAccessibleSelectionFromContext",
 710                 "(Ljavax/accessibility/AccessibleContext;I)Ljavax/accessibility/AccessibleContext;");
 711 
 712     // GetMethodID(getAccessibleSelectionCountFromContext)
 713     FIND_METHOD(getAccessibleSelectionCountFromContextMethod, bridgeClass,
 714                 "getAccessibleSelectionCountFromContext",
 715                 "(Ljavax/accessibility/AccessibleContext;)I");
 716 
 717     // GetMethodID(isAccessibleChildSelectedFromContext)
 718     FIND_METHOD(isAccessibleChildSelectedFromContextMethod, bridgeClass,
 719                 "isAccessibleChildSelectedFromContext",
 720                 "(Ljavax/accessibility/AccessibleContext;I)Z");
 721 
 722     // GetMethodID(removeAccessibleSelectionFromContext)
 723     FIND_METHOD(removeAccessibleSelectionFromContextMethod, bridgeClass,
 724                 "removeAccessibleSelectionFromContext",
 725                 "(Ljavax/accessibility/AccessibleContext;I)V");
 726 
 727     // GetMethodID(selectAllAccessibleSelectionFromContext)
 728     FIND_METHOD(selectAllAccessibleSelectionFromContextMethod, bridgeClass,
 729                 "selectAllAccessibleSelectionFromContext",
 730                 "(Ljavax/accessibility/AccessibleContext;)V");
 731 
 732 
 733     // ------- Event Notification methods
 734 
 735     // GetMethodID(addJavaEventNotification)
 736     FIND_METHOD(addJavaEventNotificationMethod, bridgeClass,
 737                 "addJavaEventNotification", "(J)V");
 738 
 739     // GetMethodID(removeJavaEventNotification)
 740     FIND_METHOD(removeJavaEventNotificationMethod, bridgeClass,
 741                 "removeJavaEventNotification", "(J)V");
 742 
 743     // GetMethodID(addAccessibilityEventNotification)
 744     FIND_METHOD(addAccessibilityEventNotificationMethod, bridgeClass,
 745                 "addAccessibilityEventNotification", "(J)V");
 746 
 747     // GetMethodID(removeAccessibilityEventNotification)
 748     FIND_METHOD(removeAccessibilityEventNotificationMethod, bridgeClass,
 749                 "removeAccessibilityEventNotification", "(J)V");
 750 
 751 
 752     // ------- AttributeSet methods
 753 
 754     // GetMethodID(getBoldFromAttributeSet)
 755     FIND_METHOD(getBoldFromAttributeSetMethod, bridgeClass,
 756                 "getBoldFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Z");
 757 
 758     // GetMethodID(getItalicFromAttributeSet)
 759     FIND_METHOD(getItalicFromAttributeSetMethod, bridgeClass,
 760                 "getItalicFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Z");
 761 
 762     // GetMethodID(getUnderlineFromAttributeSet)
 763     FIND_METHOD(getUnderlineFromAttributeSetMethod, bridgeClass,
 764                 "getUnderlineFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Z");
 765 
 766     // GetMethodID(getStrikethroughFromAttributeSet)
 767     FIND_METHOD(getStrikethroughFromAttributeSetMethod, bridgeClass,
 768                 "getStrikethroughFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Z");
 769 
 770     // GetMethodID(getSuperscriptFromAttributeSet)
 771     FIND_METHOD(getSuperscriptFromAttributeSetMethod, bridgeClass,
 772                 "getSuperscriptFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Z");
 773 
 774     // GetMethodID(getSubscriptFromAttributeSet)
 775     FIND_METHOD(getSubscriptFromAttributeSetMethod, bridgeClass,
 776                 "getSubscriptFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Z");
 777 
 778     // GetMethodID(getBackgroundColorFromAttributeSet)
 779     FIND_METHOD(getBackgroundColorFromAttributeSetMethod, bridgeClass,
 780                 "getBackgroundColorFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Ljava/lang/String;");
 781 
 782     // GetMethodID(getForegroundColorFromAttributeSet)
 783     FIND_METHOD(getForegroundColorFromAttributeSetMethod, bridgeClass,
 784                 "getForegroundColorFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Ljava/lang/String;");
 785 
 786     // GetMethodID(getFontFamilyFromAttributeSet)
 787     FIND_METHOD(getFontFamilyFromAttributeSetMethod, bridgeClass,
 788                 "getFontFamilyFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)Ljava/lang/String;");
 789 
 790     // GetMethodID(getFontSizeFromAttributeSet)
 791     FIND_METHOD(getFontSizeFromAttributeSetMethod, bridgeClass,
 792                 "getFontSizeFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)I");
 793 
 794     // GetMethodID(getAlignmentFromAttributeSet)
 795     FIND_METHOD(getAlignmentFromAttributeSetMethod, bridgeClass,
 796                 "getAlignmentFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)I");
 797 
 798     // GetMethodID(getBidiLevelFromAttributeSet)
 799     FIND_METHOD(getBidiLevelFromAttributeSetMethod, bridgeClass,
 800                 "getBidiLevelFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)I");
 801 
 802     // GetMethodID(getFirstLineIndentFromAttributeSet)
 803     FIND_METHOD(getFirstLineIndentFromAttributeSetMethod, bridgeClass,
 804                 "getFirstLineIndentFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)F");
 805 
 806     // GetMethodID(getLeftIndentFromAttributeSet)
 807     FIND_METHOD(getLeftIndentFromAttributeSetMethod, bridgeClass,
 808                 "getLeftIndentFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)F");
 809 
 810     // GetMethodID(getRightIndentFromAttributeSet)
 811     FIND_METHOD(getRightIndentFromAttributeSetMethod, bridgeClass,
 812                 "getRightIndentFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)F");
 813 
 814     // GetMethodID(getLineSpacingFromAttributeSet)
 815     FIND_METHOD(getLineSpacingFromAttributeSetMethod, bridgeClass,
 816                 "getLineSpacingFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)F");
 817 
 818     // GetMethodID(getSpaceAboveFromAttributeSet)
 819     FIND_METHOD(getSpaceAboveFromAttributeSetMethod, bridgeClass,
 820                 "getSpaceAboveFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)F");
 821 
 822     // GetMethodID(getSpaceBelowFromAttributeSet)
 823     FIND_METHOD(getSpaceBelowFromAttributeSetMethod, bridgeClass,
 824                 "getSpaceBelowFromAttributeSet", "(Ljavax/swing/text/AttributeSet;)F");
 825 
 826 
 827     /**
 828      * Additional methods for Teton
 829      */
 830 
 831     // GetMethodID(requestFocus)
 832     FIND_METHOD(requestFocusMethod, bridgeClass,
 833                 "requestFocus",
 834                 "(Ljavax/accessibility/AccessibleContext;)Z");
 835 
 836     // GetMethodID(selectTextRange)
 837     FIND_METHOD(selectTextRangeMethod, bridgeClass,
 838                 "selectTextRange",
 839                 "(Ljavax/accessibility/AccessibleContext;II)Z");
 840 
 841     // GetMethodID(getVisibleChildrenCount)
 842     FIND_METHOD(getVisibleChildrenCountMethod, bridgeClass,
 843                 "getVisibleChildrenCount",
 844                 "(Ljavax/accessibility/AccessibleContext;)I");
 845 
 846     // GetMethodID(getVisibleChild)
 847     FIND_METHOD(getVisibleChildMethod, bridgeClass,
 848                 "getVisibleChild",
 849                 "(Ljavax/accessibility/AccessibleContext;I)Ljavax/accessibility/AccessibleContext;");
 850 
 851     // GetMethodID(setCaretPosition)
 852     FIND_METHOD(setCaretPositionMethod, bridgeClass,
 853                 "setCaretPosition",
 854                 "(Ljavax/accessibility/AccessibleContext;I)Z");
 855 
 856     // GetMethodID(getVirtualAccessibleNameFromContextMethod) Ben Key
 857     FIND_METHOD(getVirtualAccessibleNameFromContextMethod, bridgeClass,
 858                 "getVirtualAccessibleNameFromContext",
 859                 "(Ljavax/accessibility/AccessibleContext;)Ljava/lang/String;");
 860 
 861     return TRUE;
 862 }
 863 
 864 // Note for the following code which makes JNI upcalls...
 865 //
 866 // Problem, bug DB 16818166, JBS DB JDK-8015400
 867 // AccessibleContext is a JOBJECT64 which is a jobject (32 bit pointer)
 868 // for a Legacy (XP) build and a jlong (64 bits) for a -32 or -64 build.
 869 // For the -32 build the lower 32 bits needs to be extracted into a jobject.
 870 // Otherwise, if AccessibleContext is used directly what happens is that
 871 // the JNI code consumes the lower 32 of its 64 bits and that is not a
 872 // problem, but then when the JNI code consumes the next 32 bits for the
 873 // reference to the role String it gets the higher 0x00000000 bits from
 874 // the 64 bit JOBJECT64 AccessibleContext variable and thus a null reference
 875 // is passed as the String reference.
 876 //
 877 // Solution:
 878 // Cast the JOBJECT64 to a jobject.  For a 64 bit compile this is basically
 879 // a noop, i.e. JOBJECT64 is a 64 bit jlong and a jobject is a 64 bit reference.
 880 // For a 32 bit compile the cast drops the high order 32 bits, i.e. JOBJECT64
 881 // is a 64 bit jlong and jobject is a 32 bit reference.  For a Legacy build
 882 // JOBJECT64 is a jobject so this is also basically a noop.  The casts are
 883 // done in the methods in JavaAccessBridge::processPackage.
 884 
 885 // -----------------------------------
 886 
 887 /**
 888  * isJavaWindow - returns whether the HWND is a Java window or not
 889  *
 890  */
 891 BOOL
 892 AccessBridgeJavaEntryPoints::isJavaWindow(jint window) {
 893     jthrowable exception;
 894     BOOL returnVal;
 895 
 896     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::isJavaWindow(%X):", window);
 897 
 898     if (isJavaWindowMethod != (jmethodID) 0) {
 899         returnVal = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject, isJavaWindowMethod, window);
 900         EXCEPTION_CHECK("Getting isJavaWindow - call to CallBooleanMethod()", FALSE);
 901         return returnVal;
 902     } else {
 903         PrintDebugString("[ERROR]: either jniEnv == 0 or isJavaWindowMethod == 0");
 904         return FALSE;
 905     }
 906 }
 907 
 908 // -----------------------------------
 909 
 910 /**
 911  * isSameObject - returns whether two object reference refer to the same object
 912  *
 913  */
 914 BOOL
 915 AccessBridgeJavaEntryPoints::isSameObject(jobject obj1, jobject obj2) {
 916     jthrowable exception;
 917     BOOL returnVal;
 918 
 919     PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::isSameObject(%p %p):", obj1, obj2);
 920 
 921     returnVal = (BOOL) jniEnv->IsSameObject((jobject)obj1, (jobject)obj2);
 922     EXCEPTION_CHECK("Calling IsSameObject", FALSE);
 923 
 924     PrintDebugString("[INFO]:   isSameObject returning %d", returnVal);
 925     return returnVal;
 926 }
 927 
 928 // -----------------------------------
 929 
 930 /**
 931  * getAccessibleContextFromHWND - returns the AccessibleContext, if any, for an HWND
 932  *
 933  */
 934 jobject
 935 AccessBridgeJavaEntryPoints::getAccessibleContextFromHWND(jint window) {
 936     jobject returnedAccessibleContext;
 937     jobject globalRef;
 938     jthrowable exception;
 939 
 940     PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::getAccessibleContextFromHWND(%X):", window);
 941 
 942     if (getAccessibleContextFromHWNDMethod != (jmethodID) 0) {
 943         returnedAccessibleContext =
 944             (jobject)jniEnv->CallObjectMethod(accessBridgeObject, getAccessibleContextFromHWNDMethod,
 945                                               window);
 946         EXCEPTION_CHECK("Getting AccessibleContextFromHWND - call to CallObjectMethod()", (jobject) 0);
 947         globalRef = (jobject)jniEnv->NewGlobalRef((jobject)returnedAccessibleContext);
 948         EXCEPTION_CHECK("Getting AccessibleContextFromHWND - call to CallObjectMethod()", (jobject) 0);
 949         return globalRef;
 950     } else {
 951         PrintDebugString("[ERROR]:  either jniEnv == 0 or getAccessibleContextFromHWNDMethod == 0");
 952         return (jobject) 0;
 953     }
 954 }
 955 
 956 // -----------------------------------
 957 
 958 /**
 959  * getHWNDFromAccessibleContext - returns the HWND for an AccessibleContext, if any
 960  *      returns (HWND)0 on error.
 961  */
 962 HWND
 963 AccessBridgeJavaEntryPoints::getHWNDFromAccessibleContext(jobject accessibleContext) {
 964     jthrowable exception;
 965     HWND rHWND;
 966 
 967     PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::getHWNDFromAccessibleContext(%X):",
 968                      accessibleContext);
 969 
 970     if (getHWNDFromAccessibleContextMethod != (jmethodID) 0) {
 971         rHWND = (HWND)jniEnv->CallIntMethod(accessBridgeObject, getHWNDFromAccessibleContextMethod,
 972                                             accessibleContext);
 973         EXCEPTION_CHECK("Getting HWNDFromAccessibleContext - call to CallIntMethod()", (HWND)0);
 974         PrintDebugString("[INFO]: rHWND = %X", rHWND);
 975         return rHWND;
 976     } else {
 977         PrintDebugString("[ERROR]: either jniEnv == 0 or getHWNDFromAccessibleContextMethod == 0");
 978         return (HWND)0;
 979     }
 980 }
 981 
 982 
 983 /* ====== Utility methods ===== */
 984 
 985 /**
 986  * Sets a text field to the specified string.  Returns whether successful;
 987  */
 988 BOOL
 989 AccessBridgeJavaEntryPoints::setTextContents(const jobject accessibleContext, const wchar_t *text) {
 990     jthrowable exception;
 991     BOOL result = FALSE;
 992 
 993     PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::setTextContents(%p, %ls):",
 994                      accessibleContext, text);
 995 
 996     if (setTextContentsMethod != (jmethodID) 0) {
 997 
 998         // create a Java String for the text
 999         jstring textString = jniEnv->NewString(text, (jsize)wcslen(text));
1000         if (textString == 0) {
1001             PrintDebugString("[ERROR]:    NewString failed");
1002             return FALSE;
1003         }
1004 
1005         result = (BOOL)jniEnv->CallBooleanMethod(accessBridgeObject,
1006                                                  setTextContentsMethod,
1007                                                  accessibleContext, textString);
1008         EXCEPTION_CHECK("setTextContents - call to CallBooleanMethod()", FALSE);
1009         PrintDebugString("[INFO]:     result = %d", result);
1010         return result;
1011     } else {
1012         PrintDebugString("[ERROR]: either jniEnv == 0 or setTextContentsMethod == 0");
1013         return result;
1014     }
1015 }
1016 
1017 /**
1018  * Returns the Accessible Context of a Page Tab object that is the
1019  * ancestor of a given object.  If the object is a Page Tab object
1020  * or a Page Tab ancestor object was found, returns the object
1021  * AccessibleContext.
1022  * If there is no ancestor object that has an Accessible Role of Page Tab,
1023  * returns (AccessibleContext)0.
1024  */
1025 jobject
1026 AccessBridgeJavaEntryPoints::getParentWithRole(const jobject accessibleContext, const wchar_t *role) {
1027     jthrowable exception;
1028     jobject rAccessibleContext;
1029 
1030     PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::getParentWithRole(%p):",
1031                      accessibleContext);
1032 
1033     if (getParentWithRoleMethod != (jmethodID) 0) {
1034         // create a Java String for the role
1035         jstring roleName = jniEnv->NewString(role, (jsize)wcslen(role));
1036         if (roleName == 0) {
1037             PrintDebugString("[ERROR]:     NewString failed");
1038             return FALSE;
1039         }
1040 
1041         rAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
1042                                                       getParentWithRoleMethod,
1043                                                       accessibleContext, roleName);
1044         EXCEPTION_CHECK("Getting ParentWithRole - call to CallObjectMethod()", (AccessibleContext)0);
1045         PrintDebugString("[INFO]:     rAccessibleContext = %p", rAccessibleContext);
1046         jobject globalRef = jniEnv->NewGlobalRef(rAccessibleContext);
1047         EXCEPTION_CHECK("Getting ParentWithRole - call to NewGlobalRef()", FALSE);
1048         PrintDebugString("[INFO]:   Returning - returnedAccessibleContext = %p; globalRef = %p",
1049                          rAccessibleContext, globalRef);
1050         return globalRef;
1051     } else {
1052         PrintDebugString("[ERROR]: either jniEnv == 0 or getParentWithRoleMethod == 0");
1053         return 0;
1054     }
1055 }
1056 
1057 /**
1058  * Returns the Accessible Context for the top level object in
1059  * a Java Window.  This is same Accessible Context that is obtained
1060  * from GetAccessibleContextFromHWND for that window.  Returns
1061  * (AccessibleContext)0 on error.
1062  */
1063 jobject
1064 AccessBridgeJavaEntryPoints::getTopLevelObject(const jobject accessibleContext) {
1065     jthrowable exception;
1066     jobject rAccessibleContext;
1067 
1068     PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::getTopLevelObject(%p):",
1069                      accessibleContext);
1070 
1071     if (getTopLevelObjectMethod != (jmethodID) 0) {
1072         rAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
1073                                                       getTopLevelObjectMethod,
1074                                                       accessibleContext);
1075         EXCEPTION_CHECK("Getting TopLevelObject - call to CallObjectMethod()", FALSE);
1076         PrintDebugString("[INFO]:  rAccessibleContext = %p", rAccessibleContext);
1077         jobject globalRef = jniEnv->NewGlobalRef(rAccessibleContext);
1078         EXCEPTION_CHECK("Getting TopLevelObject - call to NewGlobalRef()", FALSE);
1079         PrintDebugString("[INFO]:   Returning - returnedAccessibleContext = %p; globalRef = %p",
1080                          rAccessibleContext, globalRef);
1081         return globalRef;
1082     } else {
1083         PrintDebugString("[ERROR]: either jniEnv == 0 or getTopLevelObjectMethod == 0");
1084         return 0;
1085     }
1086 }
1087 
1088 /**
1089  * If there is an Ancestor object that has an Accessible Role of
1090  * Internal Frame, returns the Accessible Context of the Internal
1091  * Frame object.  Otherwise, returns the top level object for that
1092  * Java Window.  Returns (AccessibleContext)0 on error.
1093  */
1094 jobject
1095 AccessBridgeJavaEntryPoints::getParentWithRoleElseRoot(const jobject accessibleContext, const wchar_t *role) {
1096     jthrowable exception;
1097     jobject rAccessibleContext;
1098 
1099     PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::getParentWithRoleElseRoot(%p):",
1100                      accessibleContext);
1101 
1102     if (getParentWithRoleElseRootMethod != (jmethodID) 0) {
1103 
1104         // create a Java String for the role
1105         jstring roleName = jniEnv->NewString(role, (jsize)wcslen(role));
1106         if (roleName == 0) {
1107             PrintDebugString("[ERROR]:     NewString failed");
1108             return FALSE;
1109         }
1110 
1111         rAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
1112                                                       getParentWithRoleElseRootMethod,
1113                                                       accessibleContext, roleName);
1114         EXCEPTION_CHECK("Getting ParentWithRoleElseRoot - call to CallObjectMethod()", (AccessibleContext)0);
1115         PrintDebugString("[INFO]:     rAccessibleContext = %p", rAccessibleContext);
1116         jobject globalRef = jniEnv->NewGlobalRef(rAccessibleContext);
1117         EXCEPTION_CHECK("Getting ParentWithRoleElseRoot - call to NewGlobalRef()", FALSE);
1118         PrintDebugString("[INFO]:   Returning - returnedAccessibleContext = %p; globalRef = %p",
1119                          rAccessibleContext, globalRef);
1120         return globalRef;
1121     } else {
1122         PrintDebugString("[ERROR]:  either jniEnv == 0 or getParentWithRoleElseRootMethod == 0");
1123         return 0;
1124     }
1125 }
1126 
1127 /**
1128  * Returns how deep in the object hierarchy a given object is.
1129  * The top most object in the object hierarchy has an object depth of 0.
1130  * Returns -1 on error.
1131  */
1132 jint
1133 AccessBridgeJavaEntryPoints::getObjectDepth(const jobject accessibleContext) {
1134     jthrowable exception;
1135     jint rResult;
1136 
1137     PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::getObjectDepth(%p):",
1138                      accessibleContext);
1139 
1140     if (getObjectDepthMethod != (jmethodID) 0) {
1141         rResult = jniEnv->CallIntMethod(accessBridgeObject,
1142                                         getObjectDepthMethod,
1143                                         accessibleContext);
1144         EXCEPTION_CHECK("Getting ObjectDepth - call to CallIntMethod()", -1);
1145         PrintDebugString("[INFO]:     rResult = %d", rResult);
1146         return rResult;
1147     } else {
1148         PrintDebugString("[ERROR]: either jniEnv == 0 or getObjectDepthMethod == 0");
1149         return -1;
1150     }
1151 }
1152 
1153 
1154 
1155 /**
1156  * Returns the Accessible Context of the current ActiveDescendent of an object.
1157  * Returns 0 on error.
1158  */
1159 jobject
1160 AccessBridgeJavaEntryPoints::getActiveDescendent(const jobject accessibleContext) {
1161     jthrowable exception;
1162     jobject rAccessibleContext;
1163 
1164     PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::getActiveDescendent(%p):",
1165                      accessibleContext);
1166 
1167     if (getActiveDescendentMethod != (jmethodID) 0) {
1168         rAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
1169                                                       getActiveDescendentMethod,
1170                                                       accessibleContext);
1171         EXCEPTION_CHECK("Getting ActiveDescendent - call to CallObjectMethod()", (AccessibleContext)0);
1172         PrintDebugString("[INFO]:     rAccessibleContext = %p", rAccessibleContext);
1173         jobject globalRef = jniEnv->NewGlobalRef(rAccessibleContext);
1174         EXCEPTION_CHECK("Getting ActiveDescendant - call to NewGlobalRef()", FALSE);
1175         PrintDebugString("[INFO]:   Returning - returnedAccessibleContext = %p; globalRef = %p",
1176                          rAccessibleContext, globalRef);
1177         return globalRef;
1178     } else {
1179         PrintDebugString("[ERROR]: either jniEnv == 0 or getActiveDescendentMethod == 0");
1180         return (AccessibleContext)0;
1181     }
1182 }
1183 
1184 /**
1185  * Additional methods for Teton
1186  */
1187 
1188 /**
1189  * Returns an AccessibleName for a component using an algorithm optimized
1190  * for the JAWS screen reader by Ben Key (Freedom Scientific).  This method
1191  * is only intended for JAWS. All other uses are entirely optional.
1192  *
1193  * Bug ID 4916682 - Implement JAWS AccessibleName policy
1194  */
1195 BOOL
1196 AccessBridgeJavaEntryPoints::getVirtualAccessibleName (
1197     IN const jobject object,
1198     OUT wchar_t * name,
1199     IN const int nameSize)
1200 {
1201     /*
1202       +
1203       Parameter validation
1204       +
1205     */
1206     if ((name == 0) || (nameSize == 0))
1207     {
1208         return FALSE;
1209     }
1210     ::memset (name, 0, nameSize * sizeof (wchar_t));
1211     if (0 == object)
1212     {
1213         return FALSE;
1214     }
1215 
1216     jstring js = NULL;
1217     const wchar_t * stringBytes = NULL;
1218     jthrowable exception = NULL;
1219     jsize length = 0;
1220     PrintDebugString("[INFO]:  getVirtualAccessibleName called.");
1221     if (getVirtualAccessibleNameFromContextMethod != (jmethodID) 0)
1222     {
1223         js = (jstring) jniEnv->CallObjectMethod (
1224             accessBridgeObject,
1225             getVirtualAccessibleNameFromContextMethod,
1226             object);
1227         EXCEPTION_CHECK("Getting AccessibleName - call to CallObjectMethod()", FALSE);
1228         if (js != (jstring) 0)
1229         {
1230             stringBytes = (const wchar_t *) jniEnv->GetStringChars (js, 0);
1231             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringChars()", FALSE);
1232             wcsncpy(name, stringBytes, nameSize - 1);
1233             length = jniEnv->GetStringLength(js);
1234             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleName", FALSE, js, stringBytes);
1235             jniEnv->CallVoidMethod (
1236                 accessBridgeObject,
1237                 decrementReferenceMethod, js);
1238             EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE);
1239             wPrintDebugString(L"  Accessible Name = %ls", name);
1240             jniEnv->DeleteLocalRef(js);
1241             EXCEPTION_CHECK("Getting AccessibleName - call to DeleteLocalRef()", FALSE);
1242         }
1243         else
1244         {
1245             PrintDebugString("[INFO]:   Accessible Name is null.");
1246         }
1247     }
1248     else
1249     {
1250         PrintDebugString("[INFO]: either jniEnv == 0 or getVirtualAccessibleNameFromContextMethod == 0");
1251         return FALSE;
1252     }
1253     if ( 0 != name [0] )
1254     {
1255         return TRUE;
1256     }
1257     return FALSE;
1258 }
1259 
1260 
1261 /**
1262  * Request focus for a component. Returns whether successful;
1263  *
1264  * Bug ID 4944757 - requestFocus method needed
1265  */
1266 BOOL
1267 AccessBridgeJavaEntryPoints::requestFocus(const jobject accessibleContext) {
1268 
1269     jthrowable exception;
1270     BOOL result = FALSE;
1271 
1272     PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::requestFocus(%p):",
1273                      accessibleContext);
1274 
1275     if (requestFocusMethod != (jmethodID) 0) {
1276         result = (BOOL)jniEnv->CallBooleanMethod(accessBridgeObject,
1277                                                  requestFocusMethod,
1278                                                  accessibleContext);
1279         EXCEPTION_CHECK("requestFocus - call to CallBooleanMethod()", FALSE);
1280         PrintDebugString("[INFO]:    result = %d", result);
1281         return result;
1282     } else {
1283         PrintDebugString("[ERROR]: either jniEnv == 0 or requestFocusMethod == 0");
1284         return result;
1285     }
1286 }
1287 
1288 /**
1289  * Selects text between two indices.  Selection includes the text at the start index
1290  * and the text at the end index. Returns whether successful;
1291  *
1292  * Bug ID 4944758 - selectTextRange method needed
1293  */
1294 BOOL
1295 AccessBridgeJavaEntryPoints::selectTextRange(const jobject accessibleContext, int startIndex, int endIndex) {
1296 
1297     jthrowable exception;
1298     BOOL result = FALSE;
1299 
1300     PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::selectTextRange(%p start = %d end = %d):",
1301                      accessibleContext, startIndex, endIndex);
1302 
1303     if (selectTextRangeMethod != (jmethodID) 0) {
1304         result = (BOOL)jniEnv->CallBooleanMethod(accessBridgeObject,
1305                                                  selectTextRangeMethod,
1306                                                  accessibleContext,
1307                                                  startIndex, endIndex);
1308         EXCEPTION_CHECK("selectTextRange - call to CallBooleanMethod()", FALSE);
1309         PrintDebugString("[INFO]:     result = %d", result);
1310         return result;
1311     } else {
1312         PrintDebugString("[ERROR]: either jniEnv == 0 or selectTextRangeMethod == 0");
1313         return result;
1314     }
1315 }
1316 
1317 /*
1318  * Returns whether two text attributes are the same.
1319  */
1320 static BOOL CompareAccessibleTextAttributesInfo(AccessibleTextAttributesInfo *one,
1321                                                 AccessibleTextAttributesInfo *two) {
1322     return(one->bold == two->bold
1323            && one->italic == two->italic
1324            && one->underline == two->underline
1325            && one->strikethrough == two->strikethrough
1326            && one->superscript == two->superscript
1327            && one->subscript == two->subscript
1328            && one->fontSize == two->fontSize
1329            && one->alignment == two->alignment
1330            && one->bidiLevel == two->bidiLevel
1331            && one->firstLineIndent == two->firstLineIndent
1332            && one->leftIndent == two->leftIndent
1333            && one->rightIndent == two->rightIndent
1334            && one->lineSpacing == two->lineSpacing
1335            && one->spaceAbove == two->spaceAbove
1336            && one->spaceBelow == two->spaceBelow
1337            && !wcscmp(one->backgroundColor,two->backgroundColor)
1338            && !wcscmp(one->foregroundColor,two->foregroundColor)
1339            && !wcscmp(one->fullAttributesString,two->fullAttributesString));
1340 }
1341 
1342 /**
1343  * Get text attributes between two indices.
1344  *
1345  * Only one AccessibleTextAttributesInfo structure is passed - which
1346  * contains the attributes for the first character, the function then goes
1347  * through the following characters in the range specified and stops when the
1348  * attributes are different from the first, it then returns in the passed
1349  * parameter len the number of characters with the attributes returned. In most
1350  * situations this will be all the characters, and if not the calling program
1351  * can easily get the attributes for the next characters with different
1352  * attributes
1353  *
1354  * Bug ID 4944761 - getTextAttributes between two indices method needed
1355  */
1356 
1357 /* NEW FASTER CODE!!*/
1358 BOOL
1359 AccessBridgeJavaEntryPoints::getTextAttributesInRange(const jobject accessibleContext,
1360                                                       int startIndex, int endIndex,
1361                                                       AccessibleTextAttributesInfo *attributes, short *len) {
1362 
1363     jstring js;
1364     const wchar_t *stringBytes;
1365     jthrowable exception;
1366     jsize length;
1367     BOOL result = FALSE;
1368 
1369     PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::getTextAttributesInRange(%p start = %d end = %d):",
1370                      accessibleContext, startIndex, endIndex);
1371 
1372     *len = 0;
1373     result = getAccessibleTextAttributes((jobject)accessibleContext, startIndex, attributes);
1374     if (result != TRUE) {
1375         return FALSE;
1376     }
1377     (*len)++;
1378 
1379     for (jint i = startIndex+1; i <= endIndex; i++) {
1380 
1381         AccessibleTextAttributesInfo test_attributes = *attributes;
1382         // Get the full test_attributes string at i
1383         if (getAccessibleAttributesAtIndexFromContextMethod != (jmethodID) 0) {
1384             PrintDebugString("[INFO]:  Getting full test_attributes string from Context...");
1385             js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1386                                                     getAccessibleAttributesAtIndexFromContextMethod,
1387                                                     accessibleContext, i);
1388             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallObjectMethod()", FALSE);
1389             PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
1390             if (js != (jstring) 0) {
1391                 stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1392                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringChars()", FALSE);
1393                 wcsncpy(test_attributes.fullAttributesString, stringBytes, (sizeof(test_attributes.fullAttributesString) / sizeof(wchar_t)));
1394                 length = jniEnv->GetStringLength(js);
1395                 test_attributes.fullAttributesString[length < (sizeof(test_attributes.fullAttributesString) / sizeof(wchar_t)) ?
1396                                                      length : (sizeof(test_attributes.fullAttributesString) / sizeof(wchar_t))-2] = (wchar_t) 0;
1397                 EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleAttributesAtIndex", FALSE, js, stringBytes);
1398                 jniEnv->CallVoidMethod(accessBridgeObject,
1399                                        decrementReferenceMethod, js);
1400                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallVoidMethod()", FALSE);
1401                 wPrintDebugString(L"[INFO]:  Accessible Text attributes = %ls", test_attributes.fullAttributesString);
1402                 jniEnv->DeleteLocalRef(js);
1403                 EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to DeleteLocalRef()", FALSE);
1404             } else {
1405                 PrintDebugString("[WARN]:   Accessible Text attributes is null.");
1406                 test_attributes.fullAttributesString[0] = (wchar_t) 0;
1407                 return FALSE;
1408             }
1409         } else {
1410             PrintDebugString("[ERROR]: either env == 0 or getAccessibleAttributesAtIndexFromContextMethod == 0");
1411             return FALSE;
1412         }
1413 
1414         if(wcscmp(attributes->fullAttributesString,test_attributes.fullAttributesString))
1415             break;
1416         if (result != TRUE) {
1417             return FALSE;
1418         }
1419         (*len)++;
1420     }
1421     return TRUE;
1422 }
1423 
1424 /*
1425  * Returns the number of visible children of a component
1426  *
1427  * Bug ID 4944762- getVisibleChildren for list-like components needed
1428  */
1429 int
1430 AccessBridgeJavaEntryPoints::getVisibleChildrenCount(const jobject accessibleContext) {
1431 
1432     jthrowable exception;
1433     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getVisibleChildrenCount(%p)",
1434                      accessibleContext);
1435 
1436     // get the visible children count
1437     int numChildren = jniEnv->CallIntMethod(accessBridgeObject, getVisibleChildrenCountMethod,
1438                                             accessibleContext);
1439     EXCEPTION_CHECK("##### Getting visible children count - call to CallIntMethod()", FALSE);
1440     PrintDebugString("[INFO]:   ##### visible children count = %d", numChildren);
1441 
1442     return numChildren;
1443 }
1444 
1445 
1446 /*
1447  * This method is used to iterate through the visible children of a component.  It
1448  * returns visible children information for a component starting at nStartIndex.
1449  * No more than MAX_VISIBLE_CHILDREN VisibleChildrenInfo objects will
1450  * be returned for each call to this method. Returns FALSE on error.
1451  *
1452  * Bug ID 4944762- getVisibleChildren for list-like components needed
1453  */
1454 BOOL AccessBridgeJavaEntryPoints::getVisibleChildren(const jobject accessibleContext,
1455                                                      const int nStartIndex,
1456                                                      /* OUT */ VisibleChildrenInfo *visibleChildrenInfo) {
1457 
1458     jthrowable exception;
1459 
1460     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getVisibleChildren(%p, startIndex = %d)",
1461                      accessibleContext, nStartIndex);
1462 
1463     // get the visible children count
1464     int numChildren = jniEnv->CallIntMethod(accessBridgeObject, getVisibleChildrenCountMethod,
1465                                             accessibleContext);
1466     EXCEPTION_CHECK("##### Getting visible children count - call to CallIntMethod()", FALSE);
1467     PrintDebugString("[INFO]:   ##### visible children count = %d", numChildren);
1468 
1469     if (nStartIndex >= numChildren) {
1470         return FALSE;
1471     }
1472 
1473     // get the visible children
1474     int bufIndex = 0;
1475     for (int i = nStartIndex; (i < numChildren) && (i < nStartIndex + MAX_VISIBLE_CHILDREN); i++) {
1476         PrintDebugString("[INFO]:   getting visible child %d ...", i);
1477 
1478         // get the visible child at index i
1479         jobject ac = jniEnv->CallObjectMethod(accessBridgeObject, getVisibleChildMethod,
1480                                               accessibleContext, i);
1481         EXCEPTION_CHECK("##### getVisibleChildMethod - call to CallObjectMethod()", FALSE);
1482         jobject globalRef = jniEnv->NewGlobalRef(ac);
1483         EXCEPTION_CHECK("##### getVisibleChildMethod - call to NewGlobalRef()", FALSE);
1484         visibleChildrenInfo->children[bufIndex] = (JOBJECT64)globalRef;
1485         PrintDebugString("[INFO]:   ##### visible child = %p", globalRef);
1486 
1487         bufIndex++;
1488     }
1489     visibleChildrenInfo->returnedChildrenCount = bufIndex;
1490 
1491     PrintDebugString("[INFO]:   ##### AccessBridgeJavaEntryPoints::getVisibleChildren succeeded");
1492     return TRUE;
1493 }
1494 
1495 /**
1496  * Set the caret to a text position. Returns whether successful;
1497  *
1498  * Bug ID 4944770 - setCaretPosition method needed
1499  */
1500 BOOL
1501 AccessBridgeJavaEntryPoints::setCaretPosition(const jobject accessibleContext, int position) {
1502 
1503     jthrowable exception;
1504     BOOL result = FALSE;
1505 
1506     PrintDebugString("[INFO]: In AccessBridgeJavaEntryPoints::setCaretPostion(%p position = %d):",
1507                      accessibleContext, position);
1508 
1509     if (setCaretPositionMethod != (jmethodID) 0) {
1510         result = (BOOL)jniEnv->CallBooleanMethod(accessBridgeObject,
1511                                                  setCaretPositionMethod,
1512                                                  accessibleContext, position);
1513         EXCEPTION_CHECK("setCaretPostion - call to CallBooleanMethod()", FALSE);
1514         PrintDebugString("[ERROR]:     result = %d", result);
1515         return result;
1516     } else {
1517         PrintDebugString("[ERROR]: either jniEnv == 0 or setCaretPositionMethod == 0");
1518         return result;
1519     }
1520 }
1521 
1522 
1523 // -----------------------------------
1524 
1525 /**
1526  * getVersionInfo - returns the version string of the java.version property
1527  *                  and the AccessBridge.java version
1528  *
1529  */
1530 BOOL
1531 AccessBridgeJavaEntryPoints::getVersionInfo(AccessBridgeVersionInfo *info) {
1532     jstring js;
1533     const wchar_t *stringBytes;
1534     jthrowable exception;
1535     jsize length;
1536 
1537     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getVersionInfo():");
1538 
1539     if (getJavaVersionPropertyMethod != (jmethodID) 0) {
1540         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1541                                                 getJavaVersionPropertyMethod);
1542         EXCEPTION_CHECK("Getting JavaVersionProperty - call to CallObjectMethod()", FALSE);
1543         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
1544         if (js != (jstring) 0) {
1545             length = jniEnv->GetStringLength(js);
1546             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1547             if (stringBytes == NULL) {
1548                 if (!jniEnv->ExceptionCheck()) {
1549                     PrintDebugString("[ERROR]:  *** Exception when getting JavaVersionProperty - call to GetStringChars");
1550                     jniEnv->ExceptionDescribe();
1551                     jniEnv->ExceptionClear();
1552                 }
1553                 return FALSE;
1554             }
1555             wcsncpy(info->bridgeJavaDLLVersion,
1556                     stringBytes,
1557                     sizeof(info->bridgeJavaDLLVersion)  / sizeof(wchar_t));
1558             info->bridgeJavaDLLVersion[length < (sizeof(info->bridgeJavaDLLVersion) / sizeof(wchar_t)) ?
1559                             length : (sizeof(info->bridgeJavaDLLVersion) / sizeof(wchar_t))-2] = (wchar_t) 0;
1560             wcsncpy(info->VMversion,
1561                     stringBytes,
1562                     sizeof(info->VMversion)  / sizeof(wchar_t));
1563             info->VMversion[length < (sizeof(info->VMversion) / sizeof(wchar_t)) ?
1564                             length : (sizeof(info->VMversion) / sizeof(wchar_t))-2] = (wchar_t) 0;
1565             wcsncpy(info->bridgeJavaClassVersion,
1566                     stringBytes,
1567                     sizeof(info->bridgeJavaClassVersion)  / sizeof(wchar_t));
1568             info->bridgeJavaClassVersion[length < (sizeof(info->bridgeJavaClassVersion) / sizeof(wchar_t)) ?
1569                                          length : (sizeof(info->bridgeJavaClassVersion) / sizeof(wchar_t))-2] = (wchar_t) 0;
1570             wcsncpy(info->bridgeWinDLLVersion,
1571                     stringBytes,
1572                     sizeof(info->bridgeWinDLLVersion)  / sizeof(wchar_t));
1573             info->bridgeWinDLLVersion[length < (sizeof(info->bridgeWinDLLVersion) / sizeof(wchar_t)) ?
1574                                          length : (sizeof(info->bridgeWinDLLVersion) / sizeof(wchar_t))-2] = (wchar_t) 0;
1575             jniEnv->ReleaseStringChars(js, stringBytes);
1576             EXCEPTION_CHECK("Getting JavaVersionProperty - call to ReleaseStringChars()", FALSE);
1577             jniEnv->CallVoidMethod(accessBridgeObject,
1578                                    decrementReferenceMethod, js);
1579             EXCEPTION_CHECK("Getting JavaVersionProperty - call to CallVoidMethod()", FALSE);
1580             wPrintDebugString(L"  Java version = %ls", info->VMversion);
1581             jniEnv->DeleteLocalRef(js);
1582             EXCEPTION_CHECK("Getting JavaVersionProperty - call to DeleteLocalRef()", FALSE);
1583         } else {
1584             PrintDebugString("[WARN]:   Java version is null.");
1585             info->VMversion[0] = (wchar_t) 0;
1586             return FALSE;
1587         }
1588     } else {
1589         PrintDebugString("[ERROR]:  either env == 0 or getJavaVersionPropertyMethod == 0");
1590         return FALSE;
1591     }
1592 
1593     return TRUE;
1594 }
1595 
1596 
1597 /*
1598  * Verifies the Java VM still exists and obj is an
1599  * instance of AccessibleText
1600  */
1601 BOOL AccessBridgeJavaEntryPoints::verifyAccessibleText(jobject obj) {
1602     JavaVM *vm;
1603     BOOL retval;
1604     jthrowable exception;
1605 
1606     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::verifyAccessibleText");
1607 
1608     if (jniEnv->GetJavaVM(&vm) != 0) {
1609         PrintDebugString("[ERROR]:  No Java VM");
1610         return FALSE;
1611     }
1612 
1613     if (obj == (jobject)0) {
1614         PrintDebugString("[ERROR]:  Null jobject");
1615         return FALSE;
1616     }
1617 
1618     // Copied from getAccessibleContextInfo
1619     if (getAccessibleTextFromContextMethod != (jmethodID) 0) {
1620         jobject returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
1621                                                            getAccessibleTextFromContextMethod,
1622                                                            (jobject)obj);
1623         EXCEPTION_CHECK("Getting AccessibleText - call to CallObjectMethod()", FALSE);
1624         PrintDebugString("[ERROR]:   AccessibleText = %p", returnedJobject);
1625         retval = returnedJobject != (jobject) 0;
1626         jniEnv->DeleteLocalRef(returnedJobject);
1627         EXCEPTION_CHECK("Getting AccessibleText - call to DeleteLocalRef()", FALSE);
1628     } else {
1629         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleTextFromContextMethod == 0");
1630         return FALSE;
1631     }
1632     if (retval == FALSE) {
1633         PrintDebugString("[ERROR]:  jobject is not an AccessibleText");
1634     }
1635     return retval;
1636 }
1637 
1638 
1639 /********** AccessibleContext routines ***********************************/
1640 
1641 /**
1642  * getAccessibleContextAt - performs the Java method call:
1643  *   Accessible AccessBridge.getAccessibleContextAt(x, y)
1644  *
1645  * Note: this call explicitly goes through the AccessBridge,
1646  * so that it can keep a reference the returned jobject for the JavaVM.
1647  * You must explicity call INTreleaseJavaObject() when you are through using
1648  * the Accessible returned, to let the AccessBridge know it can release the
1649  * object, so that the can then garbage collect it.
1650  *
1651  */
1652 jobject
1653 AccessBridgeJavaEntryPoints::getAccessibleContextAt(jint x, jint y, jobject accessibleContext) {
1654     jobject returnedAccessibleContext;
1655     jobject globalRef;
1656     jthrowable exception;
1657 
1658     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleContextAt(%d, %d, %p):",
1659                      x, y, accessibleContext);
1660 
1661     if (getAccessibleContextAtMethod != (jmethodID) 0) {
1662         returnedAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
1663                                                              getAccessibleContextAtMethod,
1664                                                              x, y, accessibleContext);
1665         EXCEPTION_CHECK("Getting AccessibleContextAt - call to CallObjectMethod()", FALSE);
1666         globalRef = jniEnv->NewGlobalRef(returnedAccessibleContext);
1667         EXCEPTION_CHECK("Getting AccessibleContextAt - call to NewGlobalRef()", FALSE);
1668         PrintDebugString("[INFO]:   Returning - returnedAccessibleContext = %p; globalRef = %p",
1669                          returnedAccessibleContext, globalRef);
1670         return globalRef;
1671     } else {
1672         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleContextAtMethod == 0");
1673         return (jobject) 0;
1674     }
1675 }
1676 
1677 /**
1678  * getAccessibleWithFocus - performs the Java method calls:
1679  *   Accessible Translator.getAccessible(SwingEventMonitor.getComponentWithFocus();
1680  *
1681  * Note: this call explicitly goes through the AccessBridge,
1682  * so that the AccessBridge can hide expected changes in how this functions
1683  * between JDK 1.1.x w/AccessibilityUtility classes, and JDK 1.2, when some
1684  * of this functionality may be built into the platform
1685  *
1686  */
1687 jobject
1688 AccessBridgeJavaEntryPoints::getAccessibleContextWithFocus() {
1689     jobject returnedAccessibleContext;
1690     jobject globalRef;
1691     jthrowable exception;
1692 
1693     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleContextWithFocus()");
1694 
1695     if (getAccessibleContextWithFocusMethod != (jmethodID) 0) {
1696         returnedAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
1697                                                              getAccessibleContextWithFocusMethod);
1698         EXCEPTION_CHECK("Getting AccessibleContextWithFocus - call to CallObjectMethod()", FALSE);
1699         globalRef = jniEnv->NewGlobalRef(returnedAccessibleContext);
1700         EXCEPTION_CHECK("Getting AccessibleContextWithFocus - call to NewGlobalRef()", FALSE);
1701         PrintDebugString("[INFO]:   Returning - returnedAccessibleContext = %p; globalRef = %p",
1702                          returnedAccessibleContext, globalRef);
1703         return globalRef;
1704     } else {
1705         PrintDebugString("[ERROR]:  either jniEnv == 0 or getAccessibleContextWithFocusMethod == 0");
1706         return (jobject) 0;
1707     }
1708 }
1709 
1710 /**
1711  * getAccessibleContextInfo - fills a struct with a bunch of information
1712  * contained in the Java Accessibility API
1713  *
1714  * Note: if the AccessibleContext parameter is bogus, this call will blow up
1715  *
1716  * Note: this call explicitly goes through the AccessBridge,
1717  * so that it can keep a reference the returned jobject for the JavaVM.
1718  * You must explicity call releaseJavaObject() when you are through using
1719  * the AccessibleContext returned, to let the AccessBridge know it can release the
1720  * object, so that the JavaVM can then garbage collect it.
1721  */
1722 BOOL
1723 AccessBridgeJavaEntryPoints::getAccessibleContextInfo(jobject accessibleContext, AccessibleContextInfo *info) {
1724     jstring js;
1725     const wchar_t *stringBytes;
1726     jobject returnedJobject;
1727     jthrowable exception;
1728     jsize length;
1729 
1730     PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleContextInfo(%p):", accessibleContext);
1731 
1732     ZeroMemory(info, sizeof(AccessibleContextInfo));
1733 
1734     if (accessibleContext == (jobject) 0) {
1735         PrintDebugString("[WARN]:  passed in AccessibleContext == null! (oops)");
1736         return (FALSE);
1737     }
1738 
1739     // Get the Accessible Name
1740     if (getAccessibleNameFromContextMethod != (jmethodID) 0) {
1741         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1742                                                 getAccessibleNameFromContextMethod,
1743                                                 accessibleContext);
1744         EXCEPTION_CHECK("Getting AccessibleName - call to CallObjectMethod()", FALSE);
1745         if (js != (jstring) 0) {
1746             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1747             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringChars()", FALSE);
1748             wcsncpy(info->name, stringBytes, (sizeof(info->name) / sizeof(wchar_t)));
1749             length = jniEnv->GetStringLength(js);
1750             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleName", FALSE, js, stringBytes);
1751             info->name[length < (sizeof(info->name) / sizeof(wchar_t)) ?
1752                        length : (sizeof(info->name) / sizeof(wchar_t))-2] = (wchar_t) 0;
1753             jniEnv->CallVoidMethod(accessBridgeObject,
1754                                    decrementReferenceMethod, js);
1755             EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE);
1756             wPrintDebugString(L"[INFO]:   Accessible Name = %ls", info->name);
1757             jniEnv->DeleteLocalRef(js);
1758             EXCEPTION_CHECK("Getting AccessibleName - call to DeleteLocalRef()", FALSE);
1759         } else {
1760             PrintDebugString("[WARN]:   Accessible Name is null.");
1761             info->name[0] = (wchar_t) 0;
1762         }
1763     } else {
1764         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleNameFromContextMethod == 0");
1765         return FALSE;
1766     }
1767 
1768 
1769     // Get the Accessible Description
1770     if (getAccessibleDescriptionFromContextMethod != (jmethodID) 0) {
1771         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1772                                                 getAccessibleDescriptionFromContextMethod,
1773                                                 accessibleContext);
1774         EXCEPTION_CHECK("Getting AccessibleDescription - call to CallObjectMethod()", FALSE);
1775         if (js != (jstring) 0) {
1776             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1777             EXCEPTION_CHECK("Getting AccessibleName - call to GetStringChars()", FALSE);
1778             wcsncpy(info->description, stringBytes, (sizeof(info->description) / sizeof(wchar_t)));
1779             length = jniEnv->GetStringLength(js);
1780             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleName", FALSE, js, stringBytes);
1781             info->description[length < (sizeof(info->description) / sizeof(wchar_t)) ?
1782                               length : (sizeof(info->description) / sizeof(wchar_t))-2] = (wchar_t) 0;
1783             jniEnv->CallVoidMethod(accessBridgeObject,
1784                                    decrementReferenceMethod, js);
1785             EXCEPTION_CHECK("Getting AccessibleName - call to CallVoidMethod()", FALSE);
1786             wPrintDebugString(L"[INFO]:   Accessible Description = %ls", info->description);
1787             jniEnv->DeleteLocalRef(js);
1788             EXCEPTION_CHECK("Getting AccessibleName - call to DeleteLocalRef()", FALSE);
1789         } else {
1790             PrintDebugString("[WARN]:   Accessible Description is null.");
1791             info->description[0] = (wchar_t) 0;
1792         }
1793     } else {
1794         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleDescriptionFromContextMethod == 0");
1795         return FALSE;
1796     }
1797 
1798 
1799     // Get the Accessible Role String
1800     if (getAccessibleRoleStringFromContextMethod != (jmethodID) 0) {
1801         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1802                                                 getAccessibleRoleStringFromContextMethod,
1803                                                 accessibleContext);
1804         EXCEPTION_CHECK("Getting AccessibleRole - call to CallObjectMethod()", FALSE);
1805         if (js != (jstring) 0) {
1806             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1807             EXCEPTION_CHECK("Getting AccessibleRole - call to GetStringChars()", FALSE);
1808             wcsncpy(info->role, stringBytes, (sizeof(info->role) / sizeof(wchar_t)));
1809             length = jniEnv->GetStringLength(js);
1810             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleRole", FALSE, js, stringBytes);
1811             info->role[length < (sizeof(info->role) / sizeof(wchar_t)) ?
1812                        length : (sizeof(info->role) / sizeof(wchar_t))-2] = (wchar_t) 0;
1813             jniEnv->CallVoidMethod(accessBridgeObject,
1814                                    decrementReferenceMethod, js);
1815             EXCEPTION_CHECK("Getting AccessibleRole - call to CallVoidMethod()", FALSE);
1816             wPrintDebugString(L"[INFO]:   Accessible Role = %ls", info->role);
1817             jniEnv->DeleteLocalRef(js);
1818             EXCEPTION_CHECK("Getting AccessibleRole - call to DeleteLocalRef()", FALSE);
1819         } else {
1820             PrintDebugString("[WARN]:   Accessible Role is null.");
1821             info->role[0] = (wchar_t) 0;
1822         }
1823     } else {
1824         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleRoleStringFromContextMethod == 0");
1825         return FALSE;
1826     }
1827 
1828 
1829     // Get the Accessible Role String in the en_US locale
1830     if (getAccessibleRoleStringFromContext_en_USMethod != (jmethodID) 0) {
1831         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1832                                                 getAccessibleRoleStringFromContext_en_USMethod,
1833                                                 accessibleContext);
1834         EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to CallObjectMethod()", FALSE);
1835         if (js != (jstring) 0) {
1836             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1837             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to GetStringChars()", FALSE);
1838             wcsncpy(info->role_en_US, stringBytes, (sizeof(info->role_en_US) / sizeof(wchar_t)));
1839             length = jniEnv->GetStringLength(js);
1840             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleRole_en_US", FALSE, js, stringBytes);
1841             info->role_en_US[length < (sizeof(info->role_en_US) / sizeof(wchar_t)) ?
1842                              length : (sizeof(info->role_en_US) / sizeof(wchar_t))-2] = (wchar_t) 0;
1843             jniEnv->CallVoidMethod(accessBridgeObject,
1844                                    decrementReferenceMethod, js);
1845             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to CallVoidMethod()", FALSE);
1846             wPrintDebugString(L"[INFO]:   Accessible Role en_US = %ls", info->role_en_US);
1847             jniEnv->DeleteLocalRef(js);
1848             EXCEPTION_CHECK("Getting AccessibleRole_en_US - call to DeleteLocalRef()", FALSE);
1849         } else {
1850             PrintDebugString("[WARN]:   Accessible Role en_US is null.");
1851             info->role[0] = (wchar_t) 0;
1852         }
1853     } else {
1854         PrintDebugString("[ERROR]: either env == 0 or getAccessibleRoleStringFromContext_en_USMethod == 0");
1855         return FALSE;
1856     }
1857 
1858     // Get the Accessible States String
1859     if (getAccessibleStatesStringFromContextMethod != (jmethodID) 0) {
1860         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1861                                                 getAccessibleStatesStringFromContextMethod,
1862                                                 accessibleContext);
1863         EXCEPTION_CHECK("Getting AccessibleState - call to CallObjectMethod()", FALSE);
1864         if (js != (jstring) 0) {
1865             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1866             EXCEPTION_CHECK("Getting AccessibleState - call to GetStringChars()", FALSE);
1867             wcsncpy(info->states, stringBytes, (sizeof(info->states) / sizeof(wchar_t)));
1868             length = jniEnv->GetStringLength(js);
1869             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleState", FALSE, js, stringBytes);
1870             info->states[length < (sizeof(info->states) / sizeof(wchar_t)) ?
1871                          length : (sizeof(info->states) / sizeof(wchar_t))-2] = (wchar_t) 0;
1872             jniEnv->CallVoidMethod(accessBridgeObject,
1873                                    decrementReferenceMethod, js);
1874             EXCEPTION_CHECK("Getting AccessibleState - call to CallVoidMethod()", FALSE);
1875             wPrintDebugString(L"[INFO]:   Accessible States = %ls", info->states);
1876             jniEnv->DeleteLocalRef(js);
1877             EXCEPTION_CHECK("Getting AccessibleState - call to DeleteLocalRef()", FALSE);
1878         } else {
1879             PrintDebugString("[WARN]:   Accessible States is null.");
1880             info->states[0] = (wchar_t) 0;
1881         }
1882     } else {
1883         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleStatesStringFromContextMethod == 0");
1884         return FALSE;
1885     }
1886 
1887     // Get the Accessible States String in the en_US locale
1888     if (getAccessibleStatesStringFromContext_en_USMethod != (jmethodID) 0) {
1889         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
1890                                                 getAccessibleStatesStringFromContext_en_USMethod,
1891                                                 accessibleContext);
1892         EXCEPTION_CHECK("Getting AccessibleState_en_US - call to CallObjectMethod()", FALSE);
1893         if (js != (jstring) 0) {
1894             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
1895             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to GetStringChars()", FALSE);
1896             wcsncpy(info->states_en_US, stringBytes, (sizeof(info->states_en_US) / sizeof(wchar_t)));
1897             length = jniEnv->GetStringLength(js);
1898             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleState_en_US", FALSE, js, stringBytes);
1899             info->states_en_US[length < (sizeof(info->states_en_US) / sizeof(wchar_t)) ?
1900                                length : (sizeof(info->states_en_US) / sizeof(wchar_t))-2] = (wchar_t) 0;
1901             jniEnv->CallVoidMethod(accessBridgeObject,
1902                                    decrementReferenceMethod, js);
1903             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to CallVoidMethod()", FALSE);
1904             wPrintDebugString(L"[INFO]:   Accessible States en_US = %ls", info->states_en_US);
1905             jniEnv->DeleteLocalRef(js);
1906             EXCEPTION_CHECK("Getting AccessibleState_en_US - call to DeleteLocalRef()", FALSE);
1907         } else {
1908             PrintDebugString("[WARN]:   Accessible States en_US is null.");
1909             info->states[0] = (wchar_t) 0;
1910         }
1911     } else {
1912         PrintDebugString("[ERROR]: either env == 0 or getAccessibleStatesStringFromContext_en_USMethod == 0");
1913         return FALSE;
1914     }
1915 
1916 
1917     // Get the index in Parent
1918     if (getAccessibleIndexInParentFromContextMethod != (jmethodID) 0) {
1919         info->indexInParent = jniEnv->CallIntMethod(accessBridgeObject,
1920                                                     getAccessibleIndexInParentFromContextMethod,
1921                                                     accessibleContext);
1922         EXCEPTION_CHECK("Getting AccessibleIndexInParent - call to CallIntMethod()", FALSE);
1923         PrintDebugString("[INFO]:   Index in Parent = %d", info->indexInParent);
1924     } else {
1925         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleIndexInParentFromContextMethod == 0");
1926         return FALSE;
1927     }
1928 
1929 
1930     PrintDebugString("[INFO]: *** jniEnv: %p; accessBridgeObject: %p; AccessibleContext: %p ***",
1931                      jniEnv, accessBridgeObject, accessibleContext);
1932 
1933     // Get the children count
1934     if (getAccessibleChildrenCountFromContextMethod != (jmethodID) 0) {
1935         info->childrenCount = jniEnv->CallIntMethod(accessBridgeObject,
1936                                                     getAccessibleChildrenCountFromContextMethod,
1937                                                     accessibleContext);
1938         EXCEPTION_CHECK("Getting AccessibleChildrenCount - call to CallIntMethod()", FALSE);
1939         PrintDebugString("[INFO]:   Children count = %d", info->childrenCount);
1940     } else {
1941         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleChildrenCountFromContextMethod == 0");
1942         return FALSE;
1943     }
1944 
1945     PrintDebugString("[INFO]: *** jniEnv: %p; accessBridgeObject: %p; AccessibleContext: %X ***",
1946                      jniEnv, accessBridgeObject, accessibleContext);
1947 
1948 
1949     // Get the x coord
1950     if (getAccessibleXcoordFromContextMethod != (jmethodID) 0) {
1951         info->x = jniEnv->CallIntMethod(accessBridgeObject,
1952                                         getAccessibleXcoordFromContextMethod,
1953                                         accessibleContext);
1954         EXCEPTION_CHECK("Getting AccessibleXcoord - call to CallIntMethod()", FALSE);
1955         PrintDebugString("[INFO]:   X coord = %d", info->x);
1956     } else {
1957         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleXcoordFromContextMethod == 0");
1958         return FALSE;
1959     }
1960 
1961     PrintDebugString("[INFO]: *** jniEnv: %X; accessBridgeObject: %X; AccessibleContext: %p ***",
1962                      jniEnv, accessBridgeObject, accessibleContext);
1963 
1964 
1965     // Get the y coord
1966     if (getAccessibleYcoordFromContextMethod != (jmethodID) 0) {
1967         info->y = jniEnv->CallIntMethod(accessBridgeObject,
1968                                         getAccessibleYcoordFromContextMethod,
1969                                         accessibleContext);
1970         EXCEPTION_CHECK("Getting AccessibleYcoord - call to CallIntMethod()", FALSE);
1971         PrintDebugString("[INFO]:   Y coord = %d", info->y);
1972     } else {
1973         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleYcoordFromContextMethod == 0");
1974         return FALSE;
1975     }
1976 
1977     // Get the width
1978     if (getAccessibleWidthFromContextMethod != (jmethodID) 0) {
1979         info->width = jniEnv->CallIntMethod(accessBridgeObject,
1980                                             getAccessibleWidthFromContextMethod,
1981                                             accessibleContext);
1982         EXCEPTION_CHECK("Getting AccessibleWidth - call to CallIntMethod()", FALSE);
1983         PrintDebugString("[INFO]:   Width = %d", info->width);
1984     } else {
1985         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleWidthFromContextMethod == 0");
1986         return FALSE;
1987     }
1988 
1989     // Get the height
1990     if (getAccessibleHeightFromContextMethod != (jmethodID) 0) {
1991         info->height = jniEnv->CallIntMethod(accessBridgeObject,
1992                                              getAccessibleHeightFromContextMethod,
1993                                              accessibleContext);
1994         EXCEPTION_CHECK("Getting AccessibleHeight - call to CallIntMethod()", FALSE);
1995         PrintDebugString("[INFO]:   Height = %d", info->height);
1996     } else {
1997         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleHeightFromContextMethod == 0");
1998         return FALSE;
1999     }
2000 
2001     // Get the AccessibleComponent
2002     if (getAccessibleComponentFromContextMethod != (jmethodID) 0) {
2003         returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
2004                                                    getAccessibleComponentFromContextMethod,
2005                                                    accessibleContext);
2006         EXCEPTION_CHECK("Getting AccessibleComponent - call to CallObjectMethod()", FALSE);
2007         PrintDebugString("[INFO]:   AccessibleComponent = %p", returnedJobject);
2008         info->accessibleComponent = (returnedJobject != (jobject) 0 ? TRUE : FALSE);
2009         jniEnv->DeleteLocalRef(returnedJobject);
2010         EXCEPTION_CHECK("Getting AccessibleComponent - call to DeleteLocalRef()", FALSE);
2011     } else {
2012         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleComponentFromContextMethod == 0");
2013         return FALSE;
2014     }
2015 
2016     // Get the AccessibleAction
2017     if (getAccessibleActionFromContextMethod != (jmethodID) 0) {
2018         returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
2019                                                    getAccessibleActionFromContextMethod,
2020                                                    accessibleContext);
2021         EXCEPTION_CHECK("Getting AccessibleAction - call to CallObjectMethod()", FALSE);
2022         PrintDebugString("[INFO]:   AccessibleAction = %p", returnedJobject);
2023         info->accessibleAction = (returnedJobject != (jobject) 0 ? TRUE : FALSE);
2024         jniEnv->DeleteLocalRef(returnedJobject);
2025         EXCEPTION_CHECK("Getting AccessibleAction - call to DeleteLocalRef()", FALSE);
2026     } else {
2027         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleActionFromContextMethod == 0");
2028         return FALSE;
2029     }
2030 
2031     // Get the AccessibleSelection
2032     if (getAccessibleSelectionFromContextMethod != (jmethodID) 0) {
2033         returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
2034                                                    getAccessibleSelectionFromContextMethod,
2035                                                    accessibleContext);
2036         EXCEPTION_CHECK("Getting AccessibleSelection - call to CallObjectMethod()", FALSE);
2037         PrintDebugString("[INFO]:   AccessibleSelection = %p", returnedJobject);
2038         info->accessibleSelection = (returnedJobject != (jobject) 0 ? TRUE : FALSE);
2039         jniEnv->DeleteLocalRef(returnedJobject);
2040         EXCEPTION_CHECK("Getting AccessibleSelection - call to DeleteLocalRef()", FALSE);
2041     } else {
2042         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleSelectionFromContextMethod == 0");
2043         return FALSE;
2044     }
2045 
2046     // Get the AccessibleTable
2047     if (getAccessibleTableFromContextMethod != (jmethodID) 0) {
2048         PrintDebugString("[INFO]: ##### Calling getAccessibleTableFromContextMethod ...");
2049         returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
2050                                                    getAccessibleTableFromContextMethod,
2051                                                    accessibleContext);
2052         PrintDebugString("[INFO]: ##### ... Returned from getAccessibleTableFromContextMethod");
2053         EXCEPTION_CHECK("##### Getting AccessibleTable - call to CallObjectMethod()", FALSE);
2054         PrintDebugString("[INFO]:   ##### AccessibleTable = %p", returnedJobject);
2055         if (returnedJobject != (jobject) 0) {
2056             info->accessibleInterfaces |= cAccessibleTableInterface;
2057         }
2058         jniEnv->DeleteLocalRef(returnedJobject);
2059         EXCEPTION_CHECK("##### Getting AccessibleTable - call to DeleteLocalRef()", FALSE);
2060 
2061         /*
2062           returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
2063           getAccessibleTableFromContextMethod,
2064           AccessibleContext);
2065           PrintDebugString("##### ... Returned from getAccessibleTableFromContextMethod");
2066           EXCEPTION_CHECK("##### Getting AccessibleTable - call to CallObjectMethod()", FALSE);
2067           PrintDebugString("  ##### AccessibleTable = %X", returnedJobject);
2068           info->accessibleTable = returnedJobject;
2069         */
2070 
2071     } else {
2072         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableFromContextMethod == 0");
2073         return FALSE;
2074     }
2075 
2076     // Get the AccessibleText
2077     if (getAccessibleTextFromContextMethod != (jmethodID) 0) {
2078         returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
2079                                                    getAccessibleTextFromContextMethod,
2080                                                    accessibleContext);
2081         EXCEPTION_CHECK("Getting AccessibleText - call to CallObjectMethod()", FALSE);
2082         PrintDebugString("[INFO]:   AccessibleText = %p", returnedJobject);
2083         info->accessibleText = (returnedJobject != (jobject) 0 ? TRUE : FALSE);
2084         jniEnv->DeleteLocalRef(returnedJobject);
2085         EXCEPTION_CHECK("Getting AccessibleText - call to DeleteLocalRef()", FALSE);
2086     } else {
2087         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleTextFromContextMethod == 0");
2088         return FALSE;
2089     }
2090 
2091     // Get the AccessibleValue
2092     if (getAccessibleValueFromContextMethod != (jmethodID) 0) {
2093         returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
2094                                                    getAccessibleValueFromContextMethod,
2095                                                    accessibleContext);
2096         EXCEPTION_CHECK("Getting AccessibleValue - call to CallObjectMethod()", FALSE);
2097         PrintDebugString("[INFO]:   AccessibleValue = %p", returnedJobject);
2098         if (returnedJobject != (jobject) 0) {
2099             info->accessibleInterfaces |= cAccessibleValueInterface;
2100         }
2101         jniEnv->DeleteLocalRef(returnedJobject);
2102         EXCEPTION_CHECK("Getting AccessibleValue - call to DeleteLocalRef()", FALSE);
2103     } else {
2104         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleValueFromContextMethod == 0");
2105         return FALSE;
2106     }
2107 
2108     // FIX
2109     // get the AccessibleHypertext
2110     if (getAccessibleHypertextMethod != (jmethodID) 0 &&
2111         getAccessibleHyperlinkCountMethod != (jmethodID) 0 &&
2112         getAccessibleHyperlinkMethod != (jmethodID) 0 &&
2113         getAccessibleHyperlinkTextMethod != (jmethodID) 0 &&
2114         getAccessibleHyperlinkStartIndexMethod != (jmethodID) 0 &&
2115         getAccessibleHyperlinkEndIndexMethod != (jmethodID) 0) {
2116         returnedJobject = jniEnv->CallObjectMethod(accessBridgeObject,
2117                                                    getAccessibleHypertextMethod,
2118                                                    accessibleContext);
2119         EXCEPTION_CHECK("Getting AccessibleHypertext - call to CallObjectMethod()", FALSE);
2120         PrintDebugString("[INFO]:   AccessibleHypertext = %p",
2121                          returnedJobject);
2122         if (returnedJobject != (jobject) 0) {
2123             info->accessibleInterfaces |= cAccessibleHypertextInterface;
2124         }
2125         jniEnv->DeleteLocalRef(returnedJobject);
2126         EXCEPTION_CHECK("Getting AccessibleHypertext - call to DeleteLocalRef()", FALSE);
2127     }
2128 
2129     // set new accessibleInterfaces flags from old BOOL values
2130     if(info->accessibleComponent)
2131         info->accessibleInterfaces |= cAccessibleComponentInterface;
2132     if(info->accessibleAction)
2133         info->accessibleInterfaces |= cAccessibleActionInterface;
2134     if(info->accessibleSelection)
2135         info->accessibleInterfaces |= cAccessibleSelectionInterface;
2136     if(info->accessibleText)
2137         info->accessibleInterfaces |= cAccessibleTextInterface;
2138     // FIX END
2139 
2140     return TRUE;
2141 }
2142 
2143 /**
2144  * getAccessibleChildFromContext - performs the Java method call:
2145  *   AccessibleContext AccessBridge.getAccessibleChildContext(AccessibleContext)
2146  *
2147  * Note: if the AccessibleContext parameter is bogus, this call will blow up
2148  *
2149  * Note: this call explicitly goes through the AccessBridge,
2150  * so that it can keep a reference the returned jobject for the JavaVM.
2151  * You must explicity call releaseJavaObject() when you are through using
2152  * the AccessibleContext returned, to let the AccessBridge know it can release the
2153  * object, so that the JavaVM can then garbage collect it.
2154  */
2155 jobject
2156 AccessBridgeJavaEntryPoints::getAccessibleChildFromContext(jobject accessibleContext, jint childIndex) {
2157     jobject returnedAccessibleContext;
2158     jobject globalRef;
2159     jthrowable exception;
2160 
2161     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleChildContext(%p, %d):",
2162                      accessibleContext, childIndex);
2163 
2164     if (getAccessibleChildFromContextMethod != (jmethodID) 0) {
2165         returnedAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
2166                                                              getAccessibleChildFromContextMethod,
2167                                                              accessibleContext, childIndex);
2168         EXCEPTION_CHECK("Getting AccessibleChild - call to CallObjectMethod()", FALSE);
2169         globalRef = jniEnv->NewGlobalRef(returnedAccessibleContext);
2170         EXCEPTION_CHECK("Getting AccessibleChild - call to NewGlobalRef()", FALSE);
2171         jniEnv->DeleteLocalRef(returnedAccessibleContext);
2172         EXCEPTION_CHECK("Getting AccessibleChild - call to DeleteLocalRef()", FALSE);
2173         PrintDebugString("[INFO]:   Returning - returnedAccessibleContext = %p; globalRef = %p",
2174                          returnedAccessibleContext, globalRef);
2175         return globalRef;
2176     } else {
2177         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleChildContextMethod == 0");
2178         return (jobject) 0;
2179     }
2180 }
2181 
2182 /**
2183  * getAccessibleParentFromContext - returns the AccessibleContext parent
2184  *
2185  */
2186 jobject
2187 AccessBridgeJavaEntryPoints::getAccessibleParentFromContext(jobject accessibleContext)
2188 {
2189     jobject returnedAccessibleContext;
2190     jobject globalRef;
2191     jthrowable exception;
2192 
2193     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleParentFromContext(%p):", accessibleContext);
2194 
2195     if (getAccessibleParentFromContextMethod != (jmethodID) 0) {
2196         returnedAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
2197                                                              getAccessibleParentFromContextMethod,
2198                                                              accessibleContext);
2199         EXCEPTION_CHECK("Getting AccessibleParent - call to CallObjectMethod()", FALSE);
2200         globalRef = jniEnv->NewGlobalRef(returnedAccessibleContext);
2201         EXCEPTION_CHECK("Getting AccessibleParent - call to NewGlobalRef()", FALSE);
2202         jniEnv->DeleteLocalRef(returnedAccessibleContext);
2203         EXCEPTION_CHECK("Getting AccessibleParent - call to DeleteLocalRef()", FALSE);
2204         PrintDebugString("[INFO]:   Returning - returnedAccessibleContext = %p; globalRef = %p",
2205                          returnedAccessibleContext, globalRef);
2206         return globalRef;
2207     } else {
2208         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleParentFromContextMethod == 0");
2209         return (jobject) 0;
2210     }
2211 }
2212 
2213 
2214 /********** AccessibleTable routines **********************************/
2215 
2216 BOOL
2217 AccessBridgeJavaEntryPoints::getAccessibleTableInfo(jobject accessibleContext,
2218                                                     AccessibleTableInfo *tableInfo) {
2219 
2220     jthrowable exception;
2221 
2222     PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableInfo(%p):",
2223                      accessibleContext);
2224 
2225     // get the table row count
2226     if (getAccessibleTableRowCountMethod != (jmethodID) 0) {
2227         tableInfo->rowCount = jniEnv->CallIntMethod(accessBridgeObject,
2228                                                     getAccessibleTableRowCountMethod,
2229                                                     accessibleContext);
2230         EXCEPTION_CHECK("##### Getting AccessibleTableRowCount - call to CallIntMethod()", FALSE);
2231         PrintDebugString("[INFO]:   ##### table row count = %d", tableInfo->rowCount);
2232     } else {
2233         PrintDebugString("[ERROR]: either env == 0 or getAccessibleRowCountMethod == 0");
2234         return FALSE;
2235     }
2236 
2237     // get the table column count
2238     if (getAccessibleTableColumnCountMethod != (jmethodID) 0) {
2239         tableInfo->columnCount = jniEnv->CallIntMethod(accessBridgeObject,
2240                                                        getAccessibleTableColumnCountMethod,
2241                                                        accessibleContext);
2242         EXCEPTION_CHECK("Getting AccessibleTableColumnCount - call to CallIntMethod()", FALSE);
2243         PrintDebugString("[INFO]:   ##### table column count = %d", tableInfo->columnCount);
2244     } else {
2245         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableColumnCountMethod == 0");
2246         return FALSE;
2247     }
2248 
2249     // get the AccessibleTable
2250     if (getAccessibleTableFromContextMethod != (jmethodID) 0) {
2251         PrintDebugString("[INFO]: ##### Calling getAccessibleTableFromContextMethod ...");
2252         jobject accTable = jniEnv->CallObjectMethod(accessBridgeObject,
2253                                                     getAccessibleTableFromContextMethod,
2254                                                     accessibleContext);
2255         PrintDebugString("[INFO]: ##### ... Returned from getAccessibleTableFromContextMethod");
2256         EXCEPTION_CHECK("##### Getting AccessibleTable - call to CallObjectMethod()", FALSE);
2257         jobject globalRef = jniEnv->NewGlobalRef(accTable);
2258         EXCEPTION_CHECK("##### Getting AccessibleTable - call to NewGlobalRef()", FALSE);
2259         tableInfo->accessibleTable = (JOBJECT64)globalRef;
2260         PrintDebugString("[INFO]:   ##### accessibleTable = %p", globalRef);
2261     } else {
2262         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableFromContextMethod == 0");
2263         return FALSE;
2264     }
2265 
2266     // cache the AccessibleContext
2267     if (getContextFromAccessibleTableMethod != (jmethodID) 0) {
2268         PrintDebugString("[INFO]: ##### Calling getContextFromAccessibleTable Method ...");
2269         jobject ac = jniEnv->CallObjectMethod(accessBridgeObject,
2270                                               getContextFromAccessibleTableMethod,
2271                                               accessibleContext);
2272         PrintDebugString("[INFO]: ##### ... Returned from getContextFromAccessibleTable Method");
2273         EXCEPTION_CHECK("##### Getting AccessibleTable - call to CallObjectMethod()", FALSE);
2274         jobject globalRef = jniEnv->NewGlobalRef(ac);
2275         EXCEPTION_CHECK("##### Getting AccessibleTable - call to NewGlobalRef()", FALSE);
2276         tableInfo->accessibleContext = (JOBJECT64)globalRef;
2277         PrintDebugString("[INFO]:   ##### accessibleContext = %p", globalRef);
2278     } else {
2279         PrintDebugString("[ERROR]: either env == 0 or getContextFromAccessibleTable Method == 0");
2280         return FALSE;
2281     }
2282 
2283     // FIX - set unused elements
2284     tableInfo->caption = NULL;
2285     tableInfo->summary = NULL;
2286 
2287     PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableInfo succeeded");
2288     return TRUE;
2289 }
2290 
2291 BOOL
2292 AccessBridgeJavaEntryPoints::getAccessibleTableCellInfo(jobject accessibleTable, jint row, jint column,
2293                                                         AccessibleTableCellInfo *tableCellInfo) {
2294 
2295     jthrowable exception;
2296 
2297     PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableCellInfo(%p): row=%d, column=%d",
2298                      accessibleTable, row, column);
2299 
2300     // FIX
2301     ZeroMemory(tableCellInfo, sizeof(AccessibleTableCellInfo));
2302     tableCellInfo->row = row;
2303     tableCellInfo->column = column;
2304     // FIX END
2305 
2306     // get the table cell index
2307     if (getAccessibleTableCellIndexMethod != (jmethodID) 0) {
2308         tableCellInfo->index = jniEnv->CallIntMethod(accessBridgeObject,
2309                                                      getAccessibleTableCellIndexMethod,
2310                                                      accessibleTable, row, column);
2311         EXCEPTION_CHECK("##### Getting AccessibleTableCellIndex - call to CallIntMethod()", FALSE);
2312         PrintDebugString("[INFO]:   ##### table cell index = %d", tableCellInfo->index);
2313     } else {
2314         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableCellIndexMethod == 0");
2315         return FALSE;
2316     }
2317 
2318     // get the table cell row extent
2319     if (getAccessibleTableCellRowExtentMethod != (jmethodID) 0) {
2320         tableCellInfo->rowExtent = jniEnv->CallIntMethod(accessBridgeObject,
2321                                                          getAccessibleTableCellRowExtentMethod,
2322                                                          accessibleTable, row, column);
2323         EXCEPTION_CHECK("##### Getting AccessibleTableCellRowExtentCount - call to CallIntMethod()", FALSE);
2324         PrintDebugString("[INFO]:   ##### table cell row extent = %d", tableCellInfo->rowExtent);
2325     } else {
2326         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableCellRowExtentMethod == 0");
2327         return FALSE;
2328     }
2329 
2330     // get the table cell column extent
2331     if (getAccessibleTableCellColumnExtentMethod != (jmethodID) 0) {
2332         tableCellInfo->columnExtent = jniEnv->CallIntMethod(accessBridgeObject,
2333                                                             getAccessibleTableCellColumnExtentMethod,
2334                                                             accessibleTable, row, column);
2335         EXCEPTION_CHECK("##### Getting AccessibleTableCellColumnExtentCount - call to CallIntMethod()", FALSE);
2336         PrintDebugString("[INFO]:  ##### table cell column extent = %d", tableCellInfo->columnExtent);
2337     } else {
2338         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableCellColumnExtentMethod == 0");
2339         return FALSE;
2340     }
2341 
2342     // get whether the table cell is selected
2343     if (isAccessibleTableCellSelectedMethod != (jmethodID) 0) {
2344         tableCellInfo->isSelected = jniEnv->CallBooleanMethod(accessBridgeObject,
2345                                                               isAccessibleTableCellSelectedMethod,
2346                                                               accessibleTable, row, column);
2347         EXCEPTION_CHECK("##### Getting isAccessibleTableCellSelected - call to CallBooleanMethod()", FALSE);
2348         PrintDebugString("[INFO]:   ##### table cell isSelected = %d", tableCellInfo->isSelected);
2349     } else {
2350         PrintDebugString("[ERROR]: either env == 0 or isAccessibleTableCellSelectedMethod == 0");
2351         return FALSE;
2352     }
2353 
2354     // get the table cell AccessibleContext
2355     if (getAccessibleTableCellAccessibleContextMethod != (jmethodID) 0) {
2356         jobject tableCellAC = jniEnv->CallObjectMethod(accessBridgeObject,
2357                                                        getAccessibleTableCellAccessibleContextMethod,
2358                                                        accessibleTable, row, column);
2359         EXCEPTION_CHECK("##### Getting AccessibleTableCellAccessibleContext - call to CallObjectMethod()", FALSE);
2360         jobject globalRef = jniEnv->NewGlobalRef(tableCellAC);
2361         EXCEPTION_CHECK("##### Getting AccessibleTableCellAccessibleContext - call to NewGlobalRef()", FALSE);
2362         tableCellInfo->accessibleContext = (JOBJECT64)globalRef;
2363         PrintDebugString("[INFO]:   ##### table cell AccessibleContext = %p", globalRef);
2364     } else {
2365         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableCellAccessibleContextMethod == 0");
2366         return FALSE;
2367     }
2368 
2369     PrintDebugString("[INFO]:  ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableCellInfo succeeded");
2370     return TRUE;
2371 }
2372 
2373 BOOL
2374 AccessBridgeJavaEntryPoints::getAccessibleTableRowHeader(jobject acParent, AccessibleTableInfo *tableInfo) {
2375 
2376     jthrowable exception;
2377 
2378     PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableRowHeader(%p):",
2379                      acParent);
2380 
2381     // get the header row count
2382     if (getAccessibleTableRowHeaderRowCountMethod != (jmethodID) 0) {
2383         tableInfo->rowCount = jniEnv->CallIntMethod(accessBridgeObject,
2384                                                     getAccessibleTableRowHeaderRowCountMethod,
2385                                                     acParent);
2386         EXCEPTION_CHECK("##### Getting AccessibleTableRowHeaderRowCount - call to CallIntMethod()", FALSE);
2387         PrintDebugString("[INFO]:   ##### table row count = %d", tableInfo->rowCount);
2388     } else {
2389         PrintDebugString("[ERROR]: either env == 0 or getAccessibleRowHeaderRowCountMethod == 0");
2390         return FALSE;
2391     }
2392 
2393     // get the header column count
2394     if (getAccessibleTableRowHeaderColumnCountMethod != (jmethodID) 0) {
2395         tableInfo->columnCount = jniEnv->CallIntMethod(accessBridgeObject,
2396                                                        getAccessibleTableRowHeaderColumnCountMethod,
2397                                                        acParent);
2398         EXCEPTION_CHECK("Getting AccessibleTableRowHeaderColumnCount - call to CallIntMethod()", FALSE);
2399         PrintDebugString("[INFO]:   ##### table column count = %d", tableInfo->columnCount);
2400     } else {
2401         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableRowHeaderColumnCountMethod == 0");
2402         return FALSE;
2403     }
2404 
2405     // get the header AccessibleTable
2406     if (getAccessibleTableRowHeaderMethod != (jmethodID) 0) {
2407         jobject accTable = jniEnv->CallObjectMethod(accessBridgeObject,
2408                                                     getAccessibleTableRowHeaderMethod,
2409                                                     acParent);
2410         EXCEPTION_CHECK("##### Getting AccessibleTableRowHeader - call to CallObjectMethod()", FALSE);
2411         jobject globalRef = jniEnv->NewGlobalRef(accTable);
2412         EXCEPTION_CHECK("##### Getting AccessibleTableRowHeader - call to NewGlobalRef()", FALSE);
2413         tableInfo->accessibleTable = (JOBJECT64)globalRef;
2414         PrintDebugString("[INFO]:   ##### row header AccessibleTable = %p", globalRef);
2415     } else {
2416         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableRowHeaderMethod == 0");
2417         return FALSE;
2418     }
2419 
2420     // FIX - set unused elements
2421     tableInfo->caption = NULL;
2422     tableInfo->summary = NULL;
2423     tableInfo->accessibleContext = NULL;
2424 
2425     PrintDebugString("[INFO]:   ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableRowHeader succeeded");
2426     return TRUE;
2427 }
2428 
2429 BOOL
2430 AccessBridgeJavaEntryPoints::getAccessibleTableColumnHeader(jobject acParent, AccessibleTableInfo *tableInfo) {
2431     jthrowable exception;
2432 
2433     PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableColumnHeader(%p):",
2434                      acParent);
2435 
2436     // get the header row count
2437     if (getAccessibleTableColumnHeaderRowCountMethod != (jmethodID) 0) {
2438         tableInfo->rowCount = jniEnv->CallIntMethod(accessBridgeObject,
2439                                                     getAccessibleTableColumnHeaderRowCountMethod,
2440                                                     acParent);
2441         EXCEPTION_CHECK("##### Getting AccessibleTableColumnHeaderRowCount - call to CallIntMethod()", FALSE);
2442         PrintDebugString("[INFO]:   ##### table row count = %d", tableInfo->rowCount);
2443     } else {
2444         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleColumnHeaderRowCountMethod == 0");
2445         return FALSE;
2446     }
2447 
2448     // get the header column count
2449     if (getAccessibleTableColumnHeaderColumnCountMethod != (jmethodID) 0) {
2450         tableInfo->columnCount = jniEnv->CallIntMethod(accessBridgeObject,
2451                                                        getAccessibleTableColumnHeaderColumnCountMethod,
2452                                                        acParent);
2453         EXCEPTION_CHECK("Getting AccessibleTableColumnHeaderColumnCount - call to CallIntMethod()", FALSE);
2454         PrintDebugString("[INFO]:   ##### table column count = %d", tableInfo->columnCount);
2455     } else {
2456         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableColumnHeaderColumnCountMethod == 0");
2457         return FALSE;
2458     }
2459     // get the header AccessibleTable
2460     if (getAccessibleTableColumnHeaderMethod != (jmethodID) 0) {
2461         jobject accTable = jniEnv->CallObjectMethod(accessBridgeObject,
2462                                                     getAccessibleTableColumnHeaderMethod,
2463                                                     acParent);
2464         EXCEPTION_CHECK("##### Getting AccessibleTableColumnHeader - call to CallObjectMethod()", FALSE);
2465         jobject globalRef = jniEnv->NewGlobalRef(accTable);
2466         EXCEPTION_CHECK("##### Getting AccessibleTableColumnHeader - call to NewGlobalRef()", FALSE);
2467         tableInfo->accessibleTable = (JOBJECT64)globalRef;
2468         PrintDebugString("[INFO]:   ##### column header AccessibleTable = %p", globalRef);
2469     } else {
2470         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableColumnHeaderMethod == 0");
2471         return FALSE;
2472     }
2473 
2474     // FIX - set unused elements
2475     tableInfo->caption = NULL;
2476     tableInfo->summary = NULL;
2477     tableInfo->accessibleContext = NULL;
2478 
2479     PrintDebugString("[INFO]:   ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableColumnHeader succeeded");
2480     return TRUE;
2481 }
2482 
2483 jobject
2484 AccessBridgeJavaEntryPoints::getAccessibleTableRowDescription(jobject acParent, jint row) {
2485 
2486     jobject returnedAccessibleContext;
2487     jobject globalRef;
2488     jthrowable exception;
2489 
2490     PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableRowDescription(%p):",
2491                      acParent);
2492 
2493     if (getAccessibleTableRowDescriptionMethod != (jmethodID) 0) {
2494         returnedAccessibleContext = jniEnv->CallObjectMethod(accessBridgeObject,
2495                                                              getAccessibleTableRowDescriptionMethod,
2496                                                              acParent, row);
2497         EXCEPTION_CHECK("Getting AccessibleTableRowDescription - call to CallObjectMethod()", FALSE);
2498         globalRef = jniEnv->NewGlobalRef(returnedAccessibleContext);
2499         EXCEPTION_CHECK("Getting AccessibleTableRowDescription - call to NewGlobalRef()", FALSE);
2500         jniEnv->DeleteLocalRef(returnedAccessibleContext);
2501         EXCEPTION_CHECK("Getting AccessibleTableRowDescription - call to DeleteLocalRef()", FALSE);
2502         PrintDebugString("[INFO]:   Returning - returnedAccessibleContext = %p; globalRef = %p",
2503                          returnedAccessibleContext, globalRef);
2504         return globalRef;
2505     } else {
2506         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableRowDescriptionMethod == 0");
2507         return (jobject) 0;
2508     }
2509 }
2510 
2511 jobject
2512 AccessBridgeJavaEntryPoints::getAccessibleTableColumnDescription(jobject acParent, jint column) {
2513 
2514     jobject returnedAccessibleContext;
2515     jobject globalRef;
2516     jthrowable exception;
2517 
2518     PrintDebugString("[INFO]: ##### Calling AccessBridgeJavaEntryPoints::getAccessibleTableColumnDescription(%p):",
2519                      acParent);
2520 
2521     if (getAccessibleTableColumnDescriptionMethod != (jmethodID) 0) {
2522         returnedAccessibleContext = jniEnv->CallObjectMethod(
2523                                                              accessBridgeObject,
2524                                                              getAccessibleTableColumnDescriptionMethod,
2525                                                              acParent, column);
2526         EXCEPTION_CHECK("Getting AccessibleTableColumnDescription - call to CallObjectMethod()", FALSE);
2527         globalRef = jniEnv->NewGlobalRef(returnedAccessibleContext);
2528         EXCEPTION_CHECK("Getting AccessibleTableColumnDescription - call to NewGlobalRef()", FALSE);
2529         jniEnv->DeleteLocalRef(returnedAccessibleContext);
2530         EXCEPTION_CHECK("Getting AccessibleTableColumnDescription - call to DeleteLocalRef()", FALSE);
2531         PrintDebugString("[INFO]:   Returning - returnedAccessibleContext = %p; globalRef = %p",
2532                          returnedAccessibleContext, globalRef);
2533         return globalRef;
2534     } else {
2535         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableColumnDescriptionMethod == 0");
2536         return (jobject) 0;
2537     }
2538 }
2539 
2540 jint
2541 AccessBridgeJavaEntryPoints::getAccessibleTableRowSelectionCount(jobject accessibleTable) {
2542 
2543     jthrowable exception;
2544     jint count;
2545 
2546     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableRowSelectionCount(%p)",
2547                      accessibleTable);
2548 
2549     // Get the table row selection count
2550     if (getAccessibleTableRowSelectionCountMethod != (jmethodID) 0) {
2551         count = jniEnv->CallIntMethod(accessBridgeObject,
2552                                       getAccessibleTableRowSelectionCountMethod,
2553                                       accessibleTable);
2554         EXCEPTION_CHECK("##### Getting AccessibleTableRowSelectionCount - call to CallIntMethod()", FALSE);
2555         PrintDebugString("[INFO]:   ##### table row selection count = %d", count);
2556         return count;
2557     } else {
2558         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableRowSelectionCountMethod == 0");
2559         return 0;
2560     }
2561 
2562     PrintDebugString("[ERROR]:   ##### AccessBridgeJavaEntryPoints::getAccessibleTableRowSelectionCount failed");
2563     return 0;
2564 }
2565 
2566 BOOL
2567 AccessBridgeJavaEntryPoints::isAccessibleTableRowSelected(jobject accessibleTable, jint row) {
2568     jthrowable exception;
2569     BOOL result;
2570 
2571     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::isAccessibleTableRowSelected(%p, %d)",
2572                      accessibleTable, row);
2573 
2574     if (isAccessibleTableRowSelectedMethod != (jmethodID) 0) {
2575         result = jniEnv->CallBooleanMethod(accessBridgeObject,
2576                                            isAccessibleTableRowSelectedMethod,
2577                                            accessibleTable, row);
2578         EXCEPTION_CHECK("##### Getting isAccessibleTableRowSelected - call to CallBooleanMethod()", FALSE);
2579         PrintDebugString("[INFO]:   ##### table row isSelected = %d", result);
2580         return result;
2581     } else {
2582         PrintDebugString("[ERROR]: either env == 0 or isAccessibleTableRowSelectedMethod == 0");
2583         return FALSE;
2584     }
2585 
2586     PrintDebugString("[ERROR]:  AccessBridgeJavaEntryPoints::isAccessibleTableRowSelected failed");
2587     return FALSE;
2588 }
2589 
2590 BOOL
2591 AccessBridgeJavaEntryPoints::getAccessibleTableRowSelections(jobject accessibleTable, jint count,
2592                                                              jint *selections) {
2593 
2594     jthrowable exception;
2595 
2596     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableRowSelections(%p, %d %p)",
2597                      accessibleTable, count, selections);
2598 
2599     if (getAccessibleTableRowSelectionsMethod == (jmethodID) 0) {
2600         return FALSE;
2601     }
2602     // Get the table row selections
2603     for (int i = 0; i < count; i++) {
2604 
2605         selections[i] = jniEnv->CallIntMethod(accessBridgeObject,
2606                                               getAccessibleTableRowSelectionsMethod,
2607                                               accessibleTable,
2608                                               i);
2609         EXCEPTION_CHECK("##### Getting AccessibleTableRowSelections - call to CallIntMethod()", FALSE);
2610         PrintDebugString("[INFO]:   ##### table row selection[%d] = %d", i, selections[i]);
2611     }
2612 
2613     PrintDebugString("[INFO]:   ##### AccessBridgeJavaEntryPoints::getAccessibleTableRowSelections succeeded");
2614     return TRUE;
2615 }
2616 
2617 
2618 jint
2619 AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelectionCount(jobject accessibleTable) {
2620 
2621     jthrowable exception;
2622     jint count;
2623 
2624     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelectionCount(%p)",
2625                      accessibleTable);
2626 
2627     // Get the table column selection count
2628     if (getAccessibleTableColumnSelectionCountMethod != (jmethodID) 0) {
2629         count = jniEnv->CallIntMethod(accessBridgeObject,
2630                                       getAccessibleTableColumnSelectionCountMethod,
2631                                       accessibleTable);
2632         EXCEPTION_CHECK("##### Getting AccessibleTableColumnSelectionCount - call to CallIntMethod()", FALSE);
2633         PrintDebugString("[INFO]:   ##### table column selection count = %d", count);
2634         return count;
2635     } else {
2636         PrintDebugString("[ERROR]: either env == 0 or getAccessibleRowCountMethod == 0");
2637         return 0;
2638     }
2639 
2640     PrintDebugString("[ERROR]:   ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelectionCount failed");
2641     return 0;
2642 }
2643 
2644 BOOL
2645 AccessBridgeJavaEntryPoints::isAccessibleTableColumnSelected(jobject accessibleTable, jint column) {
2646     jthrowable exception;
2647     BOOL result;
2648 
2649     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::isAccessibleTableColumnSelected(%p, %d)",
2650                      accessibleTable, column);
2651 
2652     if (isAccessibleTableColumnSelectedMethod != (jmethodID) 0) {
2653         result = jniEnv->CallBooleanMethod(accessBridgeObject,
2654                                            isAccessibleTableColumnSelectedMethod,
2655                                            accessibleTable, column);
2656         EXCEPTION_CHECK("##### Getting isAccessibleTableColumnSelected - call to CallBooleanMethod()", FALSE);
2657         PrintDebugString("[INFO]:   ##### table column isSelected = %d", result);
2658         return result;
2659     } else {
2660         PrintDebugString("[ERROR]:  either env == 0 or isAccessibleTableColumnSelectedMethod == 0");
2661         return FALSE;
2662     }
2663 
2664     PrintDebugString("[ERROR]:   ##### AccessBridgeJavaEntryPoints::isAccessibleTableColumnSelected failed");
2665     return FALSE;
2666 }
2667 
2668 BOOL
2669 AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelections(jobject accessibleTable, jint count,
2670                                                                 jint *selections) {
2671     jthrowable exception;
2672 
2673     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelections(%p, %d, %p)",
2674                      accessibleTable, count, selections);
2675 
2676     if (getAccessibleTableColumnSelectionsMethod == (jmethodID) 0) {
2677         return FALSE;
2678     }
2679     // Get the table column selections
2680     for (int i = 0; i < count; i++) {
2681 
2682         selections[i] = jniEnv->CallIntMethod(accessBridgeObject,
2683                                               getAccessibleTableColumnSelectionsMethod,
2684                                               accessibleTable,
2685                                               i);
2686         EXCEPTION_CHECK("##### Getting AccessibleTableColumnSelections - call to CallIntMethod()", FALSE);
2687         PrintDebugString("[INFO]:   ##### table Column selection[%d] = %d", i, selections[i]);
2688     }
2689 
2690     PrintDebugString("[INFO]:   ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumnSelections succeeded");
2691     return TRUE;
2692 }
2693 
2694 
2695 jint
2696 AccessBridgeJavaEntryPoints::getAccessibleTableRow(jobject accessibleTable, jint index) {
2697     jthrowable exception;
2698     jint result;
2699 
2700     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableRow(%p, index=%d)",
2701                      accessibleTable, index);
2702 
2703     if (getAccessibleTableRowMethod != (jmethodID) 0) {
2704         result = jniEnv->CallIntMethod(accessBridgeObject,
2705                                        getAccessibleTableRowMethod,
2706                                        accessibleTable, index);
2707         EXCEPTION_CHECK("##### Getting AccessibleTableRow - call to CallIntMethod()", FALSE);
2708         PrintDebugString("[INFO]:   ##### table row = %d", result);
2709         return result;
2710     } else {
2711         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableRowMethod == 0");
2712         return -1;
2713     }
2714 
2715     PrintDebugString("[ERROR]:   ##### AccessBridgeJavaEntryPoints::getAccessibleTableRow failed");
2716     return -1;
2717 }
2718 
2719 jint
2720 AccessBridgeJavaEntryPoints::getAccessibleTableColumn(jobject accessibleTable, jint index) {
2721     jthrowable exception;
2722     jint result;
2723 
2724     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumn(%p, index=%d)",
2725                      accessibleTable, index);
2726 
2727     if (getAccessibleTableColumnMethod != (jmethodID) 0) {
2728         result = jniEnv->CallIntMethod(accessBridgeObject,
2729                                        getAccessibleTableColumnMethod,
2730                                        accessibleTable, index);
2731         EXCEPTION_CHECK("##### Getting AccessibleTableColumn - call to CallIntMethod()", FALSE);
2732         PrintDebugString("[INFO]:   ##### table column = %d", result);
2733         return result;
2734     } else {
2735         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableColumnMethod == 0");
2736         return -1;
2737     }
2738 
2739     PrintDebugString("[ERROR]:   ##### AccessBridgeJavaEntryPoints::getAccessibleTableColumn failed");
2740     return -1;
2741 }
2742 
2743 jint
2744 AccessBridgeJavaEntryPoints::getAccessibleTableIndex(jobject accessibleTable, jint row, jint column) {
2745     jthrowable exception;
2746     jint result;
2747 
2748     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleTableIndex(%p, row=%d, col=%d)",
2749                      accessibleTable, row, column);
2750 
2751     if (getAccessibleTableIndexMethod != (jmethodID) 0) {
2752         result = jniEnv->CallIntMethod(accessBridgeObject,
2753                                        getAccessibleTableIndexMethod,
2754                                        accessibleTable, row, column);
2755         EXCEPTION_CHECK("##### Getting getAccessibleTableIndex - call to CallIntMethod()", FALSE);
2756         PrintDebugString("[INFO]:   ##### table index = %d", result);
2757         return result;
2758     } else {
2759         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTableIndexMethod == 0");
2760         return -1;
2761     }
2762 
2763     PrintDebugString("[ERROR]:   ##### AccessBridgeJavaEntryPoints::getAccessibleTableIndex failed");
2764     return -1;
2765 }
2766 
2767 /********** end AccessibleTable routines ******************************/
2768 
2769 
2770 /********** begin AccessibleRelationSet routines **********************/
2771 
2772 BOOL
2773 AccessBridgeJavaEntryPoints::getAccessibleRelationSet(jobject accessibleContext,
2774                                                       AccessibleRelationSetInfo *relationSet) {
2775 
2776     jthrowable exception;
2777     const wchar_t *stringBytes;
2778     jsize length;
2779 
2780     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleRelationSet(%p, %p)",
2781                      accessibleContext, relationSet);
2782 
2783     if (getAccessibleRelationCountMethod == (jmethodID) 0 ||
2784         getAccessibleRelationKeyMethod == (jmethodID) 0 ||
2785         getAccessibleRelationTargetCountMethod == (jmethodID) 0 ||
2786         getAccessibleRelationTargetMethod == (jmethodID) 0) {
2787         return FALSE;
2788     }
2789 
2790     // Get the relations set count
2791     relationSet->relationCount = jniEnv->CallIntMethod(accessBridgeObject,
2792                                                        getAccessibleRelationCountMethod,
2793                                                        accessibleContext);
2794     EXCEPTION_CHECK("##### Getting AccessibleRelationCount - call to CallIntMethod()", FALSE);
2795     PrintDebugString("[INFO]:   ##### AccessibleRelation count = %d", relationSet->relationCount);
2796 
2797 
2798     // Get the relation set
2799     for (int i = 0; i < relationSet->relationCount && i < MAX_RELATIONS; i++) {
2800 
2801         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
2802                                                        getAccessibleRelationKeyMethod,
2803                                                        accessibleContext,
2804                                                        i);
2805 
2806         EXCEPTION_CHECK("Getting AccessibleRelationKey - call to CallObjectMethod()", FALSE);
2807         if (js != (jstring) 0) {
2808             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
2809             EXCEPTION_CHECK("Getting AccessibleRelation key - call to GetStringChars()", FALSE);
2810             wcsncpy(relationSet->relations[i].key, stringBytes, (sizeof(relationSet->relations[i].key ) / sizeof(wchar_t)));
2811             length = jniEnv->GetStringLength(js);
2812             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleRelation key", FALSE, js, stringBytes);
2813             relationSet->relations[i].key [length < (sizeof(relationSet->relations[i].key ) / sizeof(wchar_t)) ?
2814                                            length : (sizeof(relationSet->relations[i].key ) / sizeof(wchar_t))-2] = (wchar_t) 0;
2815             // jniEnv->CallVoidMethod(accessBridgeObject,
2816             //                        decrementReferenceMethod, js);
2817             //EXCEPTION_CHECK("Getting AccessibleRelation key - call to CallVoidMethod()", FALSE);
2818             PrintDebugString("[INFO]: ##### AccessibleRelation key = %ls", relationSet->relations[i].key );
2819             jniEnv->DeleteLocalRef(js);
2820             EXCEPTION_CHECK("Getting AccessibleRelation key - call to DeleteLocalRef()", FALSE);
2821         } else {
2822             PrintDebugString("[WARN]:   AccessibleRelation key is null.");
2823             relationSet->relations[i].key [0] = (wchar_t) 0;
2824         }
2825 
2826         relationSet->relations[i].targetCount = jniEnv->CallIntMethod(accessBridgeObject,
2827                                                                       getAccessibleRelationTargetCountMethod,
2828                                                                       accessibleContext,
2829                                                                       i);
2830 
2831         for (int j = 0; j < relationSet->relations[i].targetCount && j < MAX_RELATION_TARGETS; j++) {
2832             jobject target = jniEnv->CallObjectMethod(accessBridgeObject, getAccessibleRelationTargetMethod,
2833                                                       accessibleContext, i, j);
2834             EXCEPTION_CHECK("Getting AccessibleRelationSet - call to CallObjectMethod()", FALSE);
2835             jobject globalRef = jniEnv->NewGlobalRef(target);
2836             EXCEPTION_CHECK("Getting AccessibleRelationSet - call to NewGlobalRef()", FALSE);
2837             relationSet->relations[i].targets[j] = (JOBJECT64)globalRef;
2838             PrintDebugString("[INFO]:   relation set item: %p", globalRef);
2839         }
2840     }
2841 
2842     PrintDebugString("[INFO]:   ##### AccessBridgeJavaEntryPoints::getAccessibleRelationSet succeeded");
2843     return TRUE;
2844 }
2845 
2846 
2847 /********** end AccessibleRelationSet routines ************************/
2848 
2849 
2850 /********** begin AccessibleHypertext routines **********************/
2851 
2852 BOOL
2853 AccessBridgeJavaEntryPoints::getAccessibleHypertext(jobject accessibleContext,
2854                                                     AccessibleHypertextInfo *hypertext) {
2855 
2856     jthrowable exception;
2857     const wchar_t *stringBytes;
2858     jsize length;
2859 
2860     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleHypertext(%p, %p)",
2861                      accessibleContext, hypertext);
2862 
2863     // get the AccessibleHypertext
2864     jobject ht = jniEnv->CallObjectMethod(accessBridgeObject,
2865                                           getAccessibleHypertextMethod,
2866                                           accessibleContext);
2867     EXCEPTION_CHECK("##### Getting AccessibleHypertext - call to CallObjectMethod()", FALSE);
2868     jobject globalRef = jniEnv->NewGlobalRef(ht);
2869     EXCEPTION_CHECK("##### Getting AccessibleHypertext - call to NewGlobalRef()", FALSE);
2870     hypertext->accessibleHypertext = (JOBJECT64)globalRef;
2871     PrintDebugString("[INFO]:   ##### AccessibleHypertext = %p", globalRef);
2872 
2873     if (hypertext->accessibleHypertext == 0) {
2874         PrintDebugString("[WARN]:   ##### null AccessibleHypertext; returning FALSE");
2875         return false;
2876     }
2877 
2878     // get the hyperlink count
2879     hypertext->linkCount = jniEnv->CallIntMethod(accessBridgeObject,
2880                                                  getAccessibleHyperlinkCountMethod,accessibleContext);
2881 
2882     EXCEPTION_CHECK("##### Getting hyperlink count - call to CallIntMethod()", FALSE);
2883     PrintDebugString("[INFO]:   ##### hyperlink count = %d", hypertext->linkCount);
2884 
2885 
2886     // get the hypertext links
2887     for (int i = 0; i < hypertext->linkCount && i < MAX_HYPERLINKS; i++) {
2888 
2889         // get the hyperlink
2890         jobject hl = jniEnv->CallObjectMethod(accessBridgeObject,
2891                                               getAccessibleHyperlinkMethod,
2892                                               accessibleContext,
2893                                               i);
2894         EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to CallObjectMethod()", FALSE);
2895         jobject globalRef = jniEnv->NewGlobalRef(hl);
2896         EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to NewGlobalRef()", FALSE);
2897         hypertext->links[i].accessibleHyperlink = (JOBJECT64)globalRef;
2898         PrintDebugString("[INFO]:   ##### AccessibleHyperlink = %p", globalRef);
2899 
2900         // get the hyperlink text
2901         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
2902                                                        getAccessibleHyperlinkTextMethod,
2903                                                        hypertext->links[i].accessibleHyperlink,
2904                                                        i);
2905 
2906         EXCEPTION_CHECK("Getting hyperlink text - call to CallObjectMethod()", FALSE);
2907         if (js != (jstring) 0) {
2908             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
2909             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringChars()", FALSE);
2910             wcsncpy(hypertext->links[i].text, stringBytes, (sizeof(hypertext->links[i].text) / sizeof(wchar_t)));
2911             length = jniEnv->GetStringLength(js);
2912             if (length >= (sizeof(hypertext->links[i].text) / sizeof(wchar_t))) {
2913                 length = (sizeof(hypertext->links[i].text) / sizeof(wchar_t)) - 2;
2914             }
2915             hypertext->links[i].text[length] = (wchar_t) 0;
2916             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleHyperlink text", FALSE, js, stringBytes);
2917             // jniEnv->CallVoidMethod(accessBridgeObject,
2918             //                                     decrementReferenceMethod, js);
2919             //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE);
2920             PrintDebugString("[INFO]: ##### AccessibleHyperlink text = %ls", hypertext->links[i].text );
2921             jniEnv->DeleteLocalRef(js);
2922             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to DeleteLocalRef()", FALSE);
2923         } else {
2924             PrintDebugString("[WARN]:   AccessibleHyperlink text is null.");
2925             hypertext->links[i].text[0] = (wchar_t) 0;
2926         }
2927 
2928         hypertext->links[i].startIndex = jniEnv->CallIntMethod(accessBridgeObject,
2929                                                                getAccessibleHyperlinkStartIndexMethod,
2930                                                                hypertext->links[i].accessibleHyperlink,
2931                                                                i);
2932         EXCEPTION_CHECK("##### Getting hyperlink start index - call to CallIntMethod()", FALSE);
2933         PrintDebugString("[INFO]:   ##### hyperlink start index = %d", hypertext->links[i].startIndex);
2934 
2935 
2936         hypertext->links[i].endIndex = jniEnv->CallIntMethod(accessBridgeObject,
2937                                                              getAccessibleHyperlinkEndIndexMethod,
2938                                                              hypertext->links[i].accessibleHyperlink,
2939                                                              i);
2940         EXCEPTION_CHECK("##### Getting hyperlink end index - call to CallIntMethod()", FALSE);
2941         PrintDebugString("[INFO]:   ##### hyperlink end index = %d", hypertext->links[i].endIndex);
2942 
2943     }
2944 
2945     PrintDebugString("[INFO]:   ##### AccessBridgeJavaEntryPoints::getAccessibleHypertext succeeded");
2946     return TRUE;
2947 }
2948 
2949 /*
2950  * Activates an AccessibleHyperlink
2951  */
2952 BOOL
2953 AccessBridgeJavaEntryPoints::activateAccessibleHyperlink(jobject accessibleContext,
2954                                                          jobject accessibleHyperlink) {
2955 
2956     jthrowable exception;
2957     BOOL returnVal;
2958 
2959     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::activateAccessibleHyperlink(%p, %p):",
2960                      accessibleContext, accessibleHyperlink);
2961 
2962     if (activateAccessibleHyperlinkMethod != (jmethodID) 0) {
2963         returnVal = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject, activateAccessibleHyperlinkMethod,
2964                                                      accessibleContext, accessibleHyperlink);
2965         EXCEPTION_CHECK("activateAccessibleHyperlink - call to CallBooleanMethod()", FALSE);
2966         return returnVal;
2967     } else {
2968         PrintDebugString("[ERROR]: either jniEnv == 0 or activateAccessibleHyperlinkMethod == 0");
2969         return FALSE;
2970     }
2971 }
2972 
2973 
2974 /*
2975  * This method is used to iterate through the hyperlinks in a component.  It
2976  * returns hypertext information for a component starting at hyperlink index
2977  * nStartIndex.  No more than MAX_HYPERLINKS AccessibleHypertextInfo objects will
2978  * be returned for each call to this method.
2979  * returns FALSE on error.
2980  */
2981 BOOL
2982 AccessBridgeJavaEntryPoints::getAccessibleHypertextExt(const jobject accessibleContext,
2983                                                        const jint nStartIndex,
2984                                                        /* OUT */ AccessibleHypertextInfo *hypertext) {
2985 
2986     jthrowable exception;
2987     const wchar_t *stringBytes;
2988     jsize length;
2989     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleHypertextExt(%p, %p, startIndex = %d)",
2990                      accessibleContext, hypertext, nStartIndex);
2991 
2992     // get the AccessibleHypertext
2993     jobject ht = jniEnv->CallObjectMethod(accessBridgeObject, getAccessibleHypertextMethod,
2994                                                               accessibleContext);
2995     EXCEPTION_CHECK("##### Getting AccessibleHypertext - call to CallObjectMethod()", FALSE);
2996     jobject globalRef = jniEnv->NewGlobalRef(ht);
2997     EXCEPTION_CHECK("##### Getting AccessibleHypertext - call to NewGlobalRef()", FALSE);
2998     hypertext->accessibleHypertext = (JOBJECT64)globalRef;
2999     PrintDebugString("[INFO]:   ##### AccessibleHypertext = %p", globalRef);
3000     if (hypertext->accessibleHypertext == 0) {
3001         PrintDebugString("[WARN]:   ##### null AccessibleHypertext; returning FALSE");
3002         return FALSE;
3003     }
3004 
3005     // get the hyperlink count
3006     hypertext->linkCount = jniEnv->CallIntMethod(accessBridgeObject, getAccessibleHyperlinkCountMethod,
3007                                                  accessibleContext);
3008     EXCEPTION_CHECK("##### Getting hyperlink count - call to CallIntMethod()", FALSE);
3009     PrintDebugString("[INFO]:   ##### hyperlink count = %d", hypertext->linkCount);
3010 
3011     if (nStartIndex >= hypertext->linkCount) {
3012         return FALSE;
3013     }
3014 
3015     // get the hypertext links
3016     // NOTE: To avoid a crash when there are more than MAX_HYPERLINKS (64) links
3017     // in the document, test for i < MAX_HYPERLINKS in addition to
3018     // i < hypertext->linkCount
3019     int bufIndex = 0;
3020     for (int i = nStartIndex; (i < hypertext->linkCount) && (i < nStartIndex + MAX_HYPERLINKS); i++) {
3021         PrintDebugString("[INFO]:   getting hyperlink %d ...", i);
3022 
3023         // get the hyperlink
3024         jobject hl = jniEnv->CallObjectMethod(accessBridgeObject,
3025                                               getAccessibleHyperlinkMethod,
3026                                               hypertext->accessibleHypertext,
3027                                               i);
3028         EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to CallObjectMethod()", FALSE);
3029         jobject globalRef = jniEnv->NewGlobalRef(hl);
3030         EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to NewGlobalRef()", FALSE);
3031         hypertext->links[bufIndex].accessibleHyperlink = (JOBJECT64)globalRef;
3032         PrintDebugString("[INFO]:   ##### AccessibleHyperlink = %p", globalRef);
3033 
3034         // get the hyperlink text
3035         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
3036                                                        getAccessibleHyperlinkTextMethod,
3037                                                        hypertext->links[bufIndex].accessibleHyperlink,
3038                                                        i);
3039 
3040         EXCEPTION_CHECK("Getting hyperlink text - call to CallObjectMethod()", FALSE);
3041         if (js != (jstring) 0) {
3042             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3043             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringChars()", FALSE);
3044             wcsncpy(hypertext->links[bufIndex].text, stringBytes,
3045                     (sizeof(hypertext->links[bufIndex].text) / sizeof(wchar_t)));
3046             length = jniEnv->GetStringLength(js);
3047             if (length >= (sizeof(hypertext->links[bufIndex].text) / sizeof(wchar_t))) {
3048                 length = (sizeof(hypertext->links[bufIndex].text) / sizeof(wchar_t)) - 2;
3049             }
3050             hypertext->links[bufIndex].text[length] = (wchar_t) 0;
3051             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleHyperlink text", FALSE, js, stringBytes);
3052             // jniEnv->CallVoidMethod(accessBridgeObject,
3053             //                        decrementReferenceMethod, js);
3054             //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE);
3055             PrintDebugString("[INFO]: ##### AccessibleHyperlink text = %ls", hypertext->links[bufIndex].text );
3056             jniEnv->DeleteLocalRef(js);
3057             EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to DeleteLocalRef()", FALSE);
3058 
3059         } else {
3060             PrintDebugString("[WARN]:   AccessibleHyperlink text is null.");
3061             hypertext->links[bufIndex].text[0] = (wchar_t) 0;
3062         }
3063 
3064         hypertext->links[bufIndex].startIndex = jniEnv->CallIntMethod(accessBridgeObject,
3065                                                                       getAccessibleHyperlinkStartIndexMethod,
3066                                                                       hypertext->links[bufIndex].accessibleHyperlink,
3067                                                                       i);
3068         EXCEPTION_CHECK("##### Getting hyperlink start index - call to CallIntMethod()", FALSE);
3069         PrintDebugString("[INFO]:   ##### hyperlink start index = %d", hypertext->links[bufIndex].startIndex);
3070 
3071         hypertext->links[bufIndex].endIndex = jniEnv->CallIntMethod(accessBridgeObject,
3072                                                                     getAccessibleHyperlinkEndIndexMethod,
3073                                                                     hypertext->links[bufIndex].accessibleHyperlink,
3074                                                                     i);
3075         EXCEPTION_CHECK("##### Getting hyperlink end index - call to CallIntMethod()", FALSE);
3076         PrintDebugString("[INFO]:   ##### hyperlink end index = %d", hypertext->links[bufIndex].endIndex);
3077 
3078         bufIndex++;
3079     }
3080 
3081     PrintDebugString("[INFO]:   ##### AccessBridgeJavaEntryPoints::getAccessibleHypertextExt succeeded");
3082     return TRUE;
3083 }
3084 
3085 jint AccessBridgeJavaEntryPoints::getAccessibleHyperlinkCount(const jobject accessibleContext) {
3086 
3087     jthrowable exception;
3088 
3089     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleHyperlinkCount(%X)",
3090                      accessibleContext);
3091 
3092     if (getAccessibleHyperlinkCountMethod == (jmethodID)0) {
3093         return -1;
3094     }
3095 
3096     // get the hyperlink count
3097     jint linkCount = jniEnv->CallIntMethod(accessBridgeObject, getAccessibleHyperlinkCountMethod,
3098                                            accessibleContext);
3099     EXCEPTION_CHECK("##### Getting hyperlink count - call to CallIntMethod()", -1);
3100     PrintDebugString("[INFO]:   ##### hyperlink count = %d", linkCount);
3101 
3102     return linkCount;
3103 }
3104 
3105 
3106 jint AccessBridgeJavaEntryPoints::getAccessibleHypertextLinkIndex(const jobject hypertext,
3107                                                                   const jint nIndex) {
3108 
3109     jthrowable exception;
3110 
3111     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleHypertextLinkIndex(%p, index = %d)",
3112                      hypertext, nIndex);
3113 
3114     if (getAccessibleHypertextLinkIndexMethod == (jmethodID)0) {
3115         return -1;
3116     }
3117 
3118     // get the hyperlink index
3119     jint index = jniEnv->CallIntMethod(accessBridgeObject, getAccessibleHypertextLinkIndexMethod,
3120                                        hypertext, nIndex);
3121 
3122     EXCEPTION_CHECK("##### Getting hyperlink index - call to CallIntMethod()", -1);
3123     PrintDebugString("[INFO]:   ##### hyperlink index = %d", index);
3124 
3125     return index;
3126 }
3127 
3128 BOOL AccessBridgeJavaEntryPoints::getAccessibleHyperlink(jobject hypertext,
3129                                                          const jint index,
3130                                                          /* OUT */ AccessibleHyperlinkInfo *info) {
3131 
3132     jthrowable exception;
3133     const wchar_t *stringBytes;
3134     jsize length;
3135 
3136     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleHyperlink(%p, index = %d)",
3137                      hypertext, index);
3138 
3139 
3140     // get the hyperlink
3141     jobject hl = jniEnv->CallObjectMethod(accessBridgeObject,
3142                                           getAccessibleHyperlinkMethod,
3143                                           hypertext,
3144                                           index);
3145     EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to CallObjectMethod()", FALSE);
3146     jobject globalRef = jniEnv->NewGlobalRef(hl);
3147     EXCEPTION_CHECK("##### Getting AccessibleHyperlink - call to NewGlobalRef()", FALSE);
3148     info->accessibleHyperlink = (JOBJECT64)globalRef;
3149     PrintDebugString("[INFO]:   ##### AccessibleHyperlink = %p", globalRef);
3150 
3151     // get the hyperlink text
3152     jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
3153                                                    getAccessibleHyperlinkTextMethod,
3154                                                    info->accessibleHyperlink,
3155                                                    index);
3156 
3157     EXCEPTION_CHECK("Getting hyperlink text - call to CallObjectMethod()", FALSE);
3158     if (js != (jstring) 0) {
3159         stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3160         EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to GetStringChars()", FALSE);
3161         wcsncpy(info->text, stringBytes,
3162                 (sizeof(info->text) / sizeof(wchar_t)));
3163         length = jniEnv->GetStringLength(js);
3164         if (length >= (sizeof(info->text) / sizeof(wchar_t))) {
3165             length = (sizeof(info->text) / sizeof(wchar_t)) - 2;
3166         }
3167         info->text[length] = (wchar_t) 0;
3168         EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleHyperlink text", FALSE, js, stringBytes);
3169         // jniEnv->CallVoidMethod(accessBridgeObject,
3170         //                        decrementReferenceMethod, js);
3171         //EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to CallVoidMethod()", FALSE);
3172         PrintDebugString("[INFO]: ##### AccessibleHyperlink text = %ls", info->text );
3173         jniEnv->DeleteLocalRef(js);
3174         EXCEPTION_CHECK("Getting AccessibleHyperlink text - call to DeleteLocalRef()", FALSE);
3175 
3176     } else {
3177         PrintDebugString("[WARN]:   AccessibleHyperlink text is null.");
3178         info->text[0] = (wchar_t) 0;
3179     }
3180 
3181     info->startIndex = jniEnv->CallIntMethod(accessBridgeObject,
3182                                              getAccessibleHyperlinkStartIndexMethod,
3183                                              info->accessibleHyperlink,
3184                                              index);
3185     EXCEPTION_CHECK("##### Getting hyperlink start index - call to CallIntMethod()", FALSE);
3186     PrintDebugString("[INFO]:   ##### hyperlink start index = %d", info->startIndex);
3187 
3188     info->endIndex = jniEnv->CallIntMethod(accessBridgeObject,
3189                                            getAccessibleHyperlinkEndIndexMethod,
3190                                            info->accessibleHyperlink,
3191                                            index);
3192     EXCEPTION_CHECK("##### Getting hyperlink end index - call to CallIntMethod()", FALSE);
3193     PrintDebugString("[INFO]:   ##### hyperlink end index = %d", info->endIndex);
3194 
3195     return TRUE;
3196 }
3197 
3198 
3199 /********** end AccessibleHypertext routines ************************/
3200 
3201 // Accessible Keybinding methods
3202 BOOL AccessBridgeJavaEntryPoints::getAccessibleKeyBindings(jobject accessibleContext,
3203                                                            AccessibleKeyBindings *keyBindings) {
3204 
3205     jthrowable exception;
3206 
3207     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleKeyBindings(%p, %p)",
3208                      accessibleContext, keyBindings);
3209 
3210     if (getAccessibleKeyBindingsCountMethod == (jmethodID) 0 ||
3211         getAccessibleKeyBindingCharMethod == (jmethodID) 0 ||
3212         getAccessibleKeyBindingModifiersMethod == (jmethodID) 0) {
3213         return FALSE;
3214     }
3215 
3216     // get the key binding count
3217     keyBindings->keyBindingsCount = jniEnv->CallIntMethod(accessBridgeObject,
3218                                                           getAccessibleKeyBindingsCountMethod, accessibleContext);
3219 
3220     EXCEPTION_CHECK("##### Getting key bindings count - call to CallIntMethod()", FALSE);
3221 
3222     PrintDebugString("[INFO]:   ##### key bindings count = %d", keyBindings->keyBindingsCount);
3223 
3224     // get the key bindings
3225     for (int i = 0; i < keyBindings->keyBindingsCount && i < MAX_KEY_BINDINGS; i++) {
3226 
3227         // get the key binding character
3228         keyBindings->keyBindingInfo[i].character = jniEnv->CallCharMethod(accessBridgeObject,
3229                                                                           getAccessibleKeyBindingCharMethod,
3230                                                                           accessibleContext,
3231                                                                           i);
3232         EXCEPTION_CHECK("##### Getting key binding character - call to CallCharMethod()", FALSE);
3233         PrintDebugString("[INFO]:   ##### key binding character = %c"\
3234                          "          ##### key binding character in hex = %hx"\
3235                          , keyBindings->keyBindingInfo[i].character, keyBindings->keyBindingInfo[i].character);
3236 
3237         // get the key binding modifiers
3238         keyBindings->keyBindingInfo[i].modifiers = jniEnv->CallIntMethod(accessBridgeObject,
3239                                                                          getAccessibleKeyBindingModifiersMethod,
3240                                                                          accessibleContext,
3241                                                                          i);
3242         EXCEPTION_CHECK("##### Getting key binding modifiers - call to CallIntMethod()", FALSE);
3243         PrintDebugString("[INFO]:  ##### key binding modifiers = %x", keyBindings->keyBindingInfo[i].modifiers);
3244     }
3245     return FALSE;
3246 }
3247 
3248 // AccessibleIcon methods
3249 BOOL AccessBridgeJavaEntryPoints::getAccessibleIcons(jobject accessibleContext,
3250                                                      AccessibleIcons *icons) {
3251 
3252     jthrowable exception;
3253     const wchar_t *stringBytes;
3254     jsize length;
3255 
3256     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleIcons(%p, %p)",
3257                      accessibleContext, icons);
3258 
3259     if (getAccessibleIconsCountMethod == (jmethodID) 0 ||
3260         getAccessibleIconDescriptionMethod == (jmethodID) 0 ||
3261         getAccessibleIconHeightMethod == (jmethodID) 0 ||
3262         getAccessibleIconWidthMethod == (jmethodID) 0) {
3263         PrintDebugString("[WARN]:   ##### missing method(s) !!!");
3264         return FALSE;
3265     }
3266 
3267 
3268     // get the icons count
3269     icons->iconsCount = jniEnv->CallIntMethod(accessBridgeObject,
3270                                               getAccessibleIconsCountMethod, accessibleContext);
3271 
3272     EXCEPTION_CHECK("##### Getting icons count - call to CallIntMethod()", FALSE);
3273     PrintDebugString("[INFO]:   ##### icons count = %d", icons->iconsCount);
3274 
3275 
3276     // get the icons
3277     for (int i = 0; i < icons->iconsCount && i < MAX_ICON_INFO; i++) {
3278 
3279         // get the icon description
3280         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
3281                                                        getAccessibleIconDescriptionMethod,
3282                                                        accessibleContext,
3283                                                        i);
3284 
3285         EXCEPTION_CHECK("Getting icon description - call to CallObjectMethod()", FALSE);
3286         if (js != (jstring) 0) {
3287             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3288             EXCEPTION_CHECK("Getting AccessibleIcon description - call to GetStringChars()", FALSE);
3289             wcsncpy(icons->iconInfo[i].description, stringBytes, (sizeof(icons->iconInfo[i].description) / sizeof(wchar_t)));
3290             length = jniEnv->GetStringLength(js);
3291             if (length >= (sizeof(icons->iconInfo[i].description) / sizeof(wchar_t))) {
3292                 length = (sizeof(icons->iconInfo[i].description) / sizeof(wchar_t)) - 2;
3293             }
3294             icons->iconInfo[i].description[length] = (wchar_t) 0;
3295             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleIcon description", FALSE, js, stringBytes);
3296             // jniEnv->CallVoidMethod(accessBridgeObject,
3297             //                        decrementReferenceMethod, js);
3298             //EXCEPTION_CHECK("Getting AccessibleIcon description - call to CallVoidMethod()", FALSE);
3299             PrintDebugString("[INFO]: ##### AccessibleIcon description = %ls", icons->iconInfo[i].description );
3300             jniEnv->DeleteLocalRef(js);
3301             EXCEPTION_CHECK("Getting AccessibleIcon description - call to DeleteLocalRef()", FALSE);
3302         } else {
3303             PrintDebugString("[WARN]:   AccessibleIcon description is null.");
3304             icons->iconInfo[i].description[0] = (wchar_t) 0;
3305         }
3306 
3307 
3308         // get the icon height
3309         icons->iconInfo[i].height = jniEnv->CallIntMethod(accessBridgeObject,
3310                                                           getAccessibleIconHeightMethod,
3311                                                           accessibleContext,
3312                                                           i);
3313         EXCEPTION_CHECK("##### Getting icon height - call to CallIntMethod()", FALSE);
3314         PrintDebugString("[INFO]:   ##### icon height = %d", icons->iconInfo[i].height);
3315 
3316         // get the icon width
3317         icons->iconInfo[i].width = jniEnv->CallIntMethod(accessBridgeObject,
3318                                                          getAccessibleIconWidthMethod,
3319                                                          accessibleContext,
3320                                                          i);
3321         EXCEPTION_CHECK("##### Getting icon width - call to CallIntMethod()", FALSE);
3322         PrintDebugString("[INFO]:   ##### icon width = %d", icons->iconInfo[i].width);
3323     }
3324     return FALSE;
3325 }
3326 
3327 // AccessibleActionMethods
3328 BOOL AccessBridgeJavaEntryPoints::getAccessibleActions(jobject accessibleContext,
3329                                                        AccessibleActions *actions) {
3330 
3331     jthrowable exception;
3332     const wchar_t *stringBytes;
3333     jsize length;
3334 
3335     PrintDebugString("[INFO]: ##### AccessBridgeJavaEntryPoints::getAccessibleIcons(%p, %p)",
3336                      accessibleContext, actions);
3337 
3338     if (getAccessibleActionsCountMethod == (jmethodID) 0 ||
3339         getAccessibleActionNameMethod == (jmethodID) 0) {
3340         PrintDebugString("[WARN]:   ##### missing method(s) !!!");
3341         return FALSE;
3342     }
3343 
3344 
3345     // get the icons count
3346     actions->actionsCount = jniEnv->CallIntMethod(accessBridgeObject,
3347                                                   getAccessibleActionsCountMethod,accessibleContext);
3348 
3349     EXCEPTION_CHECK("##### Getting actions count - call to CallIntMethod()", FALSE);
3350     PrintDebugString("[INFO]:   ##### key actions count = %d", actions->actionsCount);
3351 
3352 
3353     // get the actions
3354     for (int i = 0; i < actions->actionsCount && i < MAX_ACTION_INFO; i++) {
3355 
3356         // get the action name
3357         jstring js = (jstring)jniEnv->CallObjectMethod(accessBridgeObject,
3358                                                        getAccessibleActionNameMethod,
3359                                                        accessibleContext,
3360                                                        i);
3361 
3362         EXCEPTION_CHECK("Getting Action Name  - call to CallObjectMethod()", FALSE);
3363         if (js != (jstring) 0) {
3364             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3365             EXCEPTION_CHECK("Getting AccessibleAction Name  - call to GetStringChars()", FALSE);
3366             wcsncpy(actions->actionInfo[i].name , stringBytes, (sizeof(actions->actionInfo[i].name ) / sizeof(wchar_t)));
3367             length = jniEnv->GetStringLength(js);
3368             if (length >= (sizeof(actions->actionInfo[i].name ) / sizeof(wchar_t))) {
3369                 length = (sizeof(actions->actionInfo[i].name ) / sizeof(wchar_t)) - 2;
3370             }
3371             actions->actionInfo[i].name [length] = (wchar_t) 0;
3372             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleAction name", FALSE, js, stringBytes);
3373             // jniEnv->CallVoidMethod(accessBridgeObject,
3374             //                        decrementReferenceMethod, js);
3375             //EXCEPTION_CHECK("Getting AccessibleAction name  - call to CallVoidMethod()", FALSE);
3376             PrintDebugString("[INFO]: ##### AccessibleAction name  = %ls", actions->actionInfo[i].name  );
3377             jniEnv->DeleteLocalRef(js);
3378             EXCEPTION_CHECK("Getting AccessibleAction name  - call to DeleteLocalRef()", FALSE);
3379         } else {
3380             PrintDebugString("[WARN]:   AccessibleAction name  is null.");
3381             actions->actionInfo[i].name [0] = (wchar_t) 0;
3382         }
3383     }
3384     return FALSE;
3385 }
3386 
3387 BOOL AccessBridgeJavaEntryPoints::doAccessibleActions(jobject accessibleContext,
3388                                                       AccessibleActionsToDo *actionsToDo,
3389                                                       jint *failure) {
3390 
3391     jthrowable exception;
3392     BOOL returnVal;
3393 
3394     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::doAccessibleActions(%p, #actions %d %s):",
3395                      accessibleContext,
3396                      actionsToDo->actionsCount,
3397                      actionsToDo->actions[0].name);
3398 
3399     if (doAccessibleActionsMethod == (jmethodID) 0) {
3400         *failure = 0;
3401         return FALSE;
3402     }
3403 
3404     PrintDebugString("[INFO]:     doing %d actions ...", actionsToDo->actionsCount);
3405     for (int i = 0; i < actionsToDo->actionsCount && i < MAX_ACTIONS_TO_DO; i++) {
3406         PrintDebugString("[INFO]:     doing action %d: %s ...", i, actionsToDo->actions[i].name);
3407 
3408         // create a Java String for the action name
3409         wchar_t *actionName = (wchar_t *)actionsToDo->actions[i].name;
3410         jstring javaName = jniEnv->NewString(actionName, (jsize)wcslen(actionName));
3411         if (javaName == 0) {
3412             PrintDebugString("[ERROR]:     NewString failed");
3413             *failure = i;
3414             return FALSE;
3415         }
3416 
3417         returnVal = (BOOL)jniEnv->CallBooleanMethod(accessBridgeObject, doAccessibleActionsMethod,
3418                                                     accessibleContext, javaName);
3419         jniEnv->DeleteLocalRef(javaName);
3420         EXCEPTION_CHECK("doAccessibleActions - call to CallBooleanMethod()", FALSE);
3421 
3422         if (returnVal != TRUE) {
3423             PrintDebugString("[ERROR]:     Action %d failed", i);
3424             *failure = i;
3425             return FALSE;
3426         }
3427     }
3428     *failure = -1;
3429     return TRUE;
3430 }
3431 
3432 
3433 /********** AccessibleText routines ***********************************/
3434 
3435 BOOL
3436 AccessBridgeJavaEntryPoints::getAccessibleTextInfo(jobject accessibleContext,
3437                                                    AccessibleTextInfo *textInfo,
3438                                                    jint x, jint y) {
3439     jthrowable exception;
3440 
3441     // Verify the Java VM still exists and AccessibleContext is
3442     // an instance of AccessibleText
3443     if (verifyAccessibleText(accessibleContext) == FALSE) {
3444         return FALSE;
3445     }
3446 
3447     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleTextInfo(%p, %d, %d):",
3448                      accessibleContext, x, y);
3449 
3450     // Get the character count
3451     if (getAccessibleCharCountFromContextMethod != (jmethodID) 0) {
3452         textInfo->charCount = jniEnv->CallIntMethod(accessBridgeObject,
3453                                                     getAccessibleCharCountFromContextMethod,
3454                                                     accessibleContext);
3455         EXCEPTION_CHECK("Getting AccessibleCharCount - call to CallIntMethod()", FALSE);
3456         PrintDebugString("[INFO]:   Char count = %d", textInfo->charCount);
3457     } else {
3458         PrintDebugString("[ERROR]: either env == 0 or getAccessibleCharCountFromContextMethod == 0");
3459         return FALSE;
3460     }
3461 
3462     // Get the index of the caret
3463     if (getAccessibleCaretPositionFromContextMethod != (jmethodID) 0) {
3464         textInfo->caretIndex = jniEnv->CallIntMethod(accessBridgeObject,
3465                                                      getAccessibleCaretPositionFromContextMethod,
3466                                                      accessibleContext);
3467         EXCEPTION_CHECK("Getting AccessibleCaretPosition - call to CallIntMethod()", FALSE);
3468         PrintDebugString("[INFO]:   Index at caret = %d", textInfo->caretIndex);
3469     } else {
3470         PrintDebugString("[ERROR]: either env == 0 or getAccessibleCaretPositionFromContextMethod == 0");
3471         return FALSE;
3472     }
3473 
3474     // Get the index at the given point
3475     if (getAccessibleIndexAtPointFromContextMethod != (jmethodID) 0) {
3476         // If x or y is -1 return -1
3477         if (x == -1 || y == -1) {
3478             textInfo->indexAtPoint = -1;
3479         } else {
3480             textInfo->indexAtPoint = jniEnv->CallIntMethod(accessBridgeObject,
3481                                                            getAccessibleIndexAtPointFromContextMethod,
3482                                                            accessibleContext, x, y);
3483             EXCEPTION_CHECK("Getting AccessibleIndexAtPoint - call to CallIntMethod()", FALSE);
3484         }
3485         PrintDebugString("[INFO]:   Index at point = %d", textInfo->indexAtPoint);
3486     } else {
3487         PrintDebugString("[ERROR]: either env == 0 or getAccessibleIndexAtPointFromContextMethod == 0");
3488         return FALSE;
3489     }
3490     return TRUE;
3491 }
3492 
3493 BOOL
3494 AccessBridgeJavaEntryPoints::getAccessibleTextItems(jobject accessibleContext,
3495                                                     AccessibleTextItemsInfo *textItems, jint index) {
3496     jstring js;
3497     const wchar_t *stringBytes;
3498     jthrowable exception;
3499     jsize length;
3500 
3501     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleTextItems(%p):", accessibleContext);
3502 
3503     // Verify the Java VM still exists and AccessibleContext is
3504     // an instance of AccessibleText
3505     if (verifyAccessibleText(accessibleContext) == FALSE) {
3506         return FALSE;
3507     }
3508 
3509     // Get the letter at index
3510     if (getAccessibleLetterAtIndexFromContextMethod != (jmethodID) 0) {
3511         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3512                                                 getAccessibleLetterAtIndexFromContextMethod,
3513                                                 accessibleContext, index);
3514         EXCEPTION_CHECK("Getting AccessibleLetterAtIndex - call to CallIntMethod()", FALSE);
3515         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
3516         if (js != (jstring) 0) {
3517             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3518             EXCEPTION_CHECK("Getting AccessibleLetterAtIndex - call to GetStringChars()", FALSE);
3519             textItems->letter = stringBytes[0];
3520             jniEnv->ReleaseStringChars(js, stringBytes);
3521             EXCEPTION_CHECK("Getting AccessibleLetterAtIndex - call to ReleaseStringChars()", FALSE);
3522             jniEnv->CallVoidMethod(accessBridgeObject,
3523                                    decrementReferenceMethod, js);
3524             EXCEPTION_CHECK("Getting AccessibleLetterAtIndex - call to CallVoidMethod()", FALSE);
3525             PrintDebugString("[INFO]:   Accessible Text letter = %c", textItems->letter);
3526             jniEnv->DeleteLocalRef(js);
3527             EXCEPTION_CHECK("Getting AccessibleLetterAtIndex - call to DeleteLocalRef()", FALSE);
3528         } else {
3529             PrintDebugString("[WARN]:   Accessible Text letter is null.");
3530             textItems->letter = (wchar_t) 0;
3531         }
3532     } else {
3533         PrintDebugString("[ERROR]: either env == 0 or getAccessibleLetterAtIndexFromContextMethod == 0");
3534         return FALSE;
3535     }
3536 
3537 
3538     // Get the word at index
3539     if (getAccessibleWordAtIndexFromContextMethod != (jmethodID) 0) {
3540         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3541                                                 getAccessibleWordAtIndexFromContextMethod,
3542                                                 accessibleContext, index);
3543         EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to CallIntMethod()", FALSE);
3544         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
3545         if (js != (jstring) 0) {
3546             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3547             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to GetStringChars()", FALSE);
3548             wcsncpy(textItems->word, stringBytes, (sizeof(textItems->word) / sizeof(wchar_t)));
3549             length = jniEnv->GetStringLength(js);
3550             textItems->word[length < (sizeof(textItems->word) / sizeof(wchar_t)) ?
3551                             length : (sizeof(textItems->word) / sizeof(wchar_t))-2] = (wchar_t) 0;
3552             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleWordAtIndex", FALSE, js, stringBytes);
3553             jniEnv->CallVoidMethod(accessBridgeObject,
3554                                    decrementReferenceMethod, js);
3555             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to CallVoidMethod()", FALSE);
3556             wPrintDebugString(L"[INFO]:   Accessible Text word = %ls", textItems->word);
3557             jniEnv->DeleteLocalRef(js);
3558             EXCEPTION_CHECK("Getting AccessibleWordAtIndex - call to DeleteLocalRef()", FALSE);
3559         } else {
3560             PrintDebugString("[WARN]:   Accessible Text word is null.");
3561             textItems->word[0] = (wchar_t) 0;
3562         }
3563     } else {
3564         PrintDebugString("[ERROR]: either env == 0 or getAccessibleWordAtIndexFromContextMethod == 0");
3565         return FALSE;
3566     }
3567 
3568     // Get the sentence at index
3569     if (getAccessibleSentenceAtIndexFromContextMethod != (jmethodID) 0) {
3570         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3571                                                 getAccessibleSentenceAtIndexFromContextMethod,
3572                                                 accessibleContext, index);
3573         EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to CallObjectMethod()", FALSE);
3574         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
3575         if (js != (jstring) 0) {
3576             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3577             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to GetStringChars()", FALSE);
3578             wcsncpy(textItems->sentence, stringBytes, (sizeof(textItems->sentence) / sizeof(wchar_t))-2);
3579             length = jniEnv->GetStringLength(js);
3580 
3581             if (length < sizeof(textItems->sentence) / sizeof(wchar_t)) {
3582                 textItems->sentence[length] = (wchar_t) 0;
3583             } else {
3584                 textItems->sentence[(sizeof(textItems->sentence) / sizeof(wchar_t))-2] = (wchar_t) 0;
3585             }
3586             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleSentenceAtIndex", FALSE, js, stringBytes);
3587             jniEnv->CallVoidMethod(accessBridgeObject,
3588                                    decrementReferenceMethod, js);
3589             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to CallVoidMethod()", FALSE);
3590             wPrintDebugString(L"[INFO]:   Accessible Text sentence = %ls", textItems->sentence);
3591             jniEnv->DeleteLocalRef(js);
3592             EXCEPTION_CHECK("Getting AccessibleSentenceAtIndex - call to DeleteLocalRef()", FALSE);
3593         } else {
3594             PrintDebugString("[WARN]:   Accessible Text sentence is null.");
3595             textItems->sentence[0] = (wchar_t) 0;
3596         }
3597     } else {
3598         PrintDebugString("[ERROR]: either env == 0 or getAccessibleSentenceAtIndexFromContextMethod == 0");
3599         return FALSE;
3600     }
3601 
3602     return TRUE;
3603 }
3604 
3605 BOOL
3606 AccessBridgeJavaEntryPoints::getAccessibleTextSelectionInfo(jobject accessibleContext,
3607                                                             AccessibleTextSelectionInfo *selectionInfo) {
3608     jstring js;
3609     const wchar_t *stringBytes;
3610     jthrowable exception;
3611     jsize length;
3612 
3613     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleTextSelectionInfo(%p):",
3614                      accessibleContext);
3615 
3616     // Verify the Java VM still exists and AccessibleContext is
3617     // an instance of AccessibleText
3618     if (verifyAccessibleText(accessibleContext) == FALSE) {
3619         return FALSE;
3620     }
3621 
3622     // Get the selection start index
3623     if (getAccessibleTextSelectionStartFromContextMethod != (jmethodID) 0) {
3624         selectionInfo->selectionStartIndex = jniEnv->CallIntMethod(accessBridgeObject,
3625                                                                    getAccessibleTextSelectionStartFromContextMethod,
3626                                                                    accessibleContext);
3627         EXCEPTION_CHECK("Getting AccessibleTextSelectionStart - call to CallIntMethod()", FALSE);
3628         PrintDebugString("[INFO]:   Selection start = %d", selectionInfo->selectionStartIndex);
3629     } else {
3630         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleTextSelectionStartFromContextMethod == 0");
3631         return FALSE;
3632     }
3633 
3634     // Get the selection end index
3635     if (getAccessibleTextSelectionEndFromContextMethod != (jmethodID) 0) {
3636         selectionInfo->selectionEndIndex = jniEnv->CallIntMethod(accessBridgeObject,
3637                                                                  getAccessibleTextSelectionEndFromContextMethod,
3638                                                                  accessibleContext);
3639         EXCEPTION_CHECK("Getting AccessibleTextSelectionEnd - call to CallIntMethod()", FALSE);
3640         PrintDebugString("[INFO]:   Selection end = %d", selectionInfo->selectionEndIndex);
3641     } else {
3642         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTextSelectionEndFromContextMethod == 0");
3643         return FALSE;
3644     }
3645 
3646     // Get the selected text
3647     if (getAccessibleTextSelectedTextFromContextMethod != (jmethodID) 0) {
3648         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3649                                                 getAccessibleTextSelectedTextFromContextMethod,
3650                                                 accessibleContext);
3651         EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to CallObjectMethod()", FALSE);
3652         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
3653         if (js != (jstring) 0) {
3654             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3655             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to GetStringChars()", FALSE);
3656             wcsncpy(selectionInfo->selectedText, stringBytes, (sizeof(selectionInfo->selectedText) / sizeof(wchar_t)));
3657             length = jniEnv->GetStringLength(js);
3658             selectionInfo->selectedText[length < (sizeof(selectionInfo->selectedText) / sizeof(wchar_t)) ?
3659                                         length : (sizeof(selectionInfo->selectedText) / sizeof(wchar_t))-2] = (wchar_t) 0;
3660             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleTextSelectedText", FALSE, js, stringBytes);
3661             jniEnv->CallVoidMethod(accessBridgeObject,
3662                                    decrementReferenceMethod, js);
3663             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to CallVoidMethod()", FALSE);
3664             PrintDebugString("[INFO]:   Accessible's selected text = %s", selectionInfo->selectedText);
3665             jniEnv->DeleteLocalRef(js);
3666             EXCEPTION_CHECK("Getting AccessibleTextSelectedText - call to DeleteLocalRef()", FALSE);
3667         } else {
3668             PrintDebugString("[WARN]:   Accessible's selected text is null.");
3669             selectionInfo->selectedText[0] = (wchar_t) 0;
3670         }
3671     } else {
3672         PrintDebugString("[WARN]: either env == 0 or getAccessibleTextSelectedTextFromContextMethod == 0");
3673         return FALSE;
3674     }
3675     return TRUE;
3676 }
3677 
3678 BOOL
3679 AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(jobject accessibleContext, jint index, AccessibleTextAttributesInfo *attributes) {
3680     jstring js;
3681     const wchar_t *stringBytes;
3682     jobject AttributeSet;
3683     jthrowable exception;
3684     jsize length;
3685 
3686     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleTextAttributes(%p):", accessibleContext);
3687 
3688     // Verify the Java VM still exists and AccessibleContext is
3689     // an instance of AccessibleText
3690     if (verifyAccessibleText(accessibleContext) == FALSE) {
3691         return FALSE;
3692     }
3693 
3694     if (accessibleContext == (jobject) 0) {
3695         PrintDebugString("[WARN]:  passed in AccessibleContext == null! (oops)");
3696 
3697         attributes->bold = FALSE;
3698         attributes->italic = FALSE;
3699         attributes->underline = FALSE;
3700         attributes->strikethrough = FALSE;
3701         attributes->superscript = FALSE;
3702         attributes->subscript = FALSE;
3703         attributes->backgroundColor[0] = (wchar_t) 0;
3704         attributes->foregroundColor[0] = (wchar_t) 0;
3705         attributes->fontFamily[0] = (wchar_t) 0;
3706         attributes->fontSize = -1;
3707         attributes->alignment = -1;
3708         attributes->bidiLevel = -1;
3709         attributes->firstLineIndent = -1;
3710         attributes->leftIndent = -1;
3711         attributes->rightIndent = -1;
3712         attributes->lineSpacing = -1;
3713         attributes->spaceAbove = -1;
3714         attributes->spaceBelow = -1;
3715         attributes->fullAttributesString[0] = (wchar_t) 0;
3716 
3717         return (FALSE);
3718     }
3719 
3720     // Get the AttributeSet
3721     if (getAccessibleAttributeSetAtIndexFromContextMethod != (jmethodID) 0) {
3722         PrintDebugString("[INFO]:  Getting AttributeSet at index...");
3723         AttributeSet = jniEnv->CallObjectMethod(accessBridgeObject,
3724                                                 getAccessibleAttributeSetAtIndexFromContextMethod,
3725                                                 accessibleContext, index);
3726         EXCEPTION_CHECK("Getting AccessibleAttributeSetAtIndex - call to CallObjectMethod()", FALSE);
3727     } else {
3728         PrintDebugString("[ERROR]: either env == 0 or getAccessibleAttributeSetAtIndexFromContextMethod == 0");
3729         return FALSE;
3730     }
3731 
3732     // It is legal for the AttributeSet object to be null, in which case we return false!
3733     if (AttributeSet == (jobject) 0) {
3734         PrintDebugString("[WARN]:  AttributeSet returned at index is null (this is legal! - see AWT in J2SE 1.3");
3735 
3736         attributes->bold = FALSE;
3737         attributes->italic = FALSE;
3738         attributes->underline = FALSE;
3739         attributes->strikethrough = FALSE;
3740         attributes->superscript = FALSE;
3741         attributes->subscript = FALSE;
3742         attributes->backgroundColor[0] = (wchar_t) 0;
3743         attributes->foregroundColor[0] = (wchar_t) 0;
3744         attributes->fontFamily[0] = (wchar_t) 0;
3745         attributes->fontSize = -1;
3746         attributes->alignment = -1;
3747         attributes->bidiLevel = -1;
3748         attributes->firstLineIndent = -1;
3749         attributes->leftIndent = -1;
3750         attributes->rightIndent = -1;
3751         attributes->lineSpacing = -1;
3752         attributes->spaceAbove = -1;
3753         attributes->spaceBelow = -1;
3754         attributes->fullAttributesString[0] = (wchar_t) 0;
3755 
3756         return (FALSE);
3757     }
3758 
3759     // Get the bold setting
3760     if (getBoldFromAttributeSetMethod != (jmethodID) 0) {
3761         PrintDebugString("[INFO]:  Getting bold from AttributeSet...");
3762         attributes->bold = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject,
3763                                                             getBoldFromAttributeSetMethod,
3764                                                             AttributeSet);
3765         EXCEPTION_CHECK("Getting BoldFromAttributeSet - call to CallBooleanMethod()", FALSE);
3766     } else {
3767         PrintDebugString("[ERROR]: either env == 0 or getBoldFromAttributeSetMethod == 0");
3768         jniEnv->CallVoidMethod(accessBridgeObject,
3769                                decrementReferenceMethod, AttributeSet);
3770         EXCEPTION_CHECK("Getting BoldFromAttributeSet - call to CallVoidMethod()", FALSE);
3771         jniEnv->DeleteLocalRef(AttributeSet);
3772         EXCEPTION_CHECK("Getting BoldFromAttributeSet - call to DeleteLocalRef()", FALSE);
3773         return FALSE;
3774     }
3775 
3776     // Get the italic setting
3777     if (getItalicFromAttributeSetMethod != (jmethodID) 0) {
3778         PrintDebugString("[INFO]:  Getting italic from AttributeSet...");
3779         attributes->italic = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject,
3780                                                               getItalicFromAttributeSetMethod,
3781                                                               AttributeSet);
3782         EXCEPTION_CHECK("Getting ItalicFromAttributeSet - call to CallBooleanMethod()", FALSE);
3783     } else {
3784         PrintDebugString("[ERROR]: either env == 0 or getItalicdFromAttributeSetMethod == 0");
3785         jniEnv->CallVoidMethod(accessBridgeObject,
3786                                decrementReferenceMethod, AttributeSet);
3787         EXCEPTION_CHECK("Getting ItalicFromAttributeSet - call to CallVoidMethod()", FALSE);
3788         jniEnv->DeleteLocalRef(AttributeSet);
3789         EXCEPTION_CHECK("Getting ItalicFromAttributeSet - call to DeleteLocalRef()", FALSE);
3790         return FALSE;
3791     }
3792 
3793     // Get the underline setting
3794     if (getUnderlineFromAttributeSetMethod != (jmethodID) 0) {
3795         PrintDebugString("[INFO]:  Getting underline from AttributeSet...");
3796         attributes->underline = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject,
3797                                                                  getUnderlineFromAttributeSetMethod,
3798                                                                  AttributeSet);
3799         EXCEPTION_CHECK("Getting UnderlineFromAttributeSet - call to CallBooleanMethod()", FALSE);
3800     } else {
3801         PrintDebugString("[ERROR]:  either env == 0 or getUnderlineFromAttributeSetMethod == 0");
3802         jniEnv->CallVoidMethod(accessBridgeObject,
3803                                decrementReferenceMethod, AttributeSet);
3804         EXCEPTION_CHECK("Getting UnderlineFromAttributeSet - call to CallVoidMethod()", FALSE);
3805         jniEnv->DeleteLocalRef(AttributeSet);
3806         EXCEPTION_CHECK("Getting UnderlineFromAttributeSet - call to DeleteLocalRef()", FALSE);
3807         return FALSE;
3808     }
3809 
3810     // Get the strikethrough setting
3811     if (getStrikethroughFromAttributeSetMethod != (jmethodID) 0) {
3812         PrintDebugString("[INFO]:  Getting strikethrough from AttributeSet...");
3813         attributes->strikethrough = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject,
3814                                                                      getStrikethroughFromAttributeSetMethod,
3815                                                                      AttributeSet);
3816         EXCEPTION_CHECK("Getting StrikethroughFromAttributeSet - call to CallBooleanMethod()", FALSE);
3817     } else {
3818         PrintDebugString("[ERROR]: either env == 0 or getStrikethroughFromAttributeSetMethod == 0");
3819         jniEnv->CallVoidMethod(accessBridgeObject,
3820                                decrementReferenceMethod, AttributeSet);
3821         EXCEPTION_CHECK("Getting StrikethroughFromAttributeSet - call to CallVoidMethod()", FALSE);
3822         jniEnv->DeleteLocalRef(AttributeSet);
3823         EXCEPTION_CHECK("Getting StrikethroughFromAttributeSet - call to DeleteLocalRef()", FALSE);
3824         return FALSE;
3825     }
3826 
3827     // Get the superscript setting
3828     if (getSuperscriptFromAttributeSetMethod != (jmethodID) 0) {
3829         PrintDebugString("[INFO]:  Getting superscript from AttributeSet...");
3830         attributes->superscript = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject,
3831                                                                    getSuperscriptFromAttributeSetMethod,
3832                                                                    AttributeSet);
3833         EXCEPTION_CHECK("Getting SuperscriptFromAttributeSet - call to CallBooleanMethod()", FALSE);
3834     } else {
3835         PrintDebugString("[ERROR]: either env == 0 or getSuperscripteFromAttributeSetMethod == 0");
3836         jniEnv->CallVoidMethod(accessBridgeObject,
3837                                decrementReferenceMethod, AttributeSet);
3838         EXCEPTION_CHECK("Getting SuperscriptFromAttributeSet - call to CallVoidMethod()", FALSE);
3839         jniEnv->DeleteLocalRef(AttributeSet);
3840         EXCEPTION_CHECK("Getting SuperscriptFromAttributeSet - call to DeleteLocalRef()", FALSE);
3841         return FALSE;
3842     }
3843 
3844     // Get the subscript setting
3845     if (getSubscriptFromAttributeSetMethod != (jmethodID) 0) {
3846         PrintDebugString("[INFO]:  Getting subscript from AttributeSet...");
3847         attributes->subscript = (BOOL) jniEnv->CallBooleanMethod(accessBridgeObject,
3848                                                                  getSubscriptFromAttributeSetMethod,
3849                                                                  AttributeSet);
3850         EXCEPTION_CHECK("Getting SubscriptFromAttributeSet - call to CallBooleanMethod()", FALSE);
3851     } else {
3852         PrintDebugString("[ERROR]: either env == 0 or getSubscriptFromAttributeSetMethod == 0");
3853         jniEnv->CallVoidMethod(accessBridgeObject,
3854                                decrementReferenceMethod, AttributeSet);
3855         EXCEPTION_CHECK("Getting SubscriptFromAttributeSet - call to CallVoidMethod()", FALSE);
3856         jniEnv->DeleteLocalRef(AttributeSet);
3857         EXCEPTION_CHECK("Getting SubscriptFromAttributeSet - call to DeleteLocalRef()", FALSE);
3858         return FALSE;
3859     }
3860 
3861     // Get the backgroundColor setting
3862     if (getBackgroundColorFromAttributeSetMethod != (jmethodID) 0) {
3863         PrintDebugString("[INFO]:  Getting backgroundColor from AttributeSet...");
3864         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3865                                                 getBackgroundColorFromAttributeSetMethod,
3866                                                 AttributeSet);
3867         EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to CallObjectMethod()", FALSE);
3868         if (js != (jstring) 0) {
3869             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3870             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to GetStringChars()", FALSE);
3871             wcsncpy(attributes->backgroundColor, stringBytes, (sizeof(attributes->backgroundColor) / sizeof(wchar_t)));
3872             length = jniEnv->GetStringLength(js);
3873             attributes->backgroundColor[length < (sizeof(attributes->backgroundColor) / sizeof(wchar_t)) ?
3874                                         length : (sizeof(attributes->backgroundColor) / sizeof(wchar_t))-2] = (wchar_t) 0;
3875             EXCEPTION_CHECK_WITH_RELEASE("Getting BackgroundColorFromAttributeSet", FALSE, js, stringBytes);
3876             jniEnv->CallVoidMethod(accessBridgeObject,
3877                                    decrementReferenceMethod, js);
3878             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
3879             wPrintDebugString(L"[INFO]:   AttributeSet's background color = %ls", attributes->backgroundColor);
3880             jniEnv->DeleteLocalRef(js);
3881             EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE);
3882         } else {
3883             PrintDebugString("[WARN]:   AttributeSet's background color is null.");
3884             attributes->backgroundColor[0] = (wchar_t) 0;
3885         }
3886     } else {
3887         PrintDebugString("[ERROR]: either env == 0 or getBackgroundColorFromAttributeSetMethod == 0");
3888         jniEnv->CallVoidMethod(accessBridgeObject,
3889                                decrementReferenceMethod, AttributeSet);
3890         EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
3891         jniEnv->DeleteLocalRef(AttributeSet);
3892         EXCEPTION_CHECK("Getting BackgroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE);
3893         return FALSE;
3894     }
3895 
3896     // Get the foregroundColor setting
3897     if (getForegroundColorFromAttributeSetMethod != (jmethodID) 0) {
3898         PrintDebugString("[INFO]:  Getting foregroundColor from AttributeSet...");
3899         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3900                                                 getForegroundColorFromAttributeSetMethod,
3901                                                 AttributeSet);
3902         EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to CallObjectMethod()", FALSE);
3903         if (js != (jstring) 0) {
3904             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3905             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to GetStringChars()", FALSE);
3906             wcsncpy(attributes->foregroundColor, stringBytes, (sizeof(attributes->foregroundColor) / sizeof(wchar_t)));
3907             length = jniEnv->GetStringLength(js);
3908             attributes->foregroundColor[length < (sizeof(attributes->foregroundColor) / sizeof(wchar_t)) ?
3909                                         length : (sizeof(attributes->foregroundColor) / sizeof(wchar_t))-2] = (wchar_t) 0;
3910             EXCEPTION_CHECK_WITH_RELEASE("Getting ForegroundColorFromAttributeSet", FALSE, js, stringBytes);
3911             jniEnv->CallVoidMethod(accessBridgeObject,
3912                                    decrementReferenceMethod, js);
3913             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
3914             wPrintDebugString(L"[INFO]:   AttributeSet's foreground color = %ls", attributes->foregroundColor);
3915             jniEnv->DeleteLocalRef(js);
3916             EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE);
3917         } else {
3918             PrintDebugString("[WARN]:   AttributeSet's foreground color is null.");
3919             attributes->foregroundColor[0] = (wchar_t) 0;
3920         }
3921     } else {
3922         PrintDebugString("[ERROR]: either env == 0 or getForegroundColorFromAttributeSetMethod == 0");
3923         jniEnv->CallVoidMethod(accessBridgeObject,
3924                                decrementReferenceMethod, AttributeSet);
3925         EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to CallVoidMethod()", FALSE);
3926         jniEnv->DeleteLocalRef(AttributeSet);
3927         EXCEPTION_CHECK("Getting ForegroundColorFromAttributeSet - call to DeleteLocalRef()", FALSE);
3928         return FALSE;
3929     }
3930 
3931     // Get the fontFamily setting
3932     if (getFontFamilyFromAttributeSetMethod != (jmethodID) 0) {
3933         PrintDebugString("[INFO]:  Getting fontFamily from AttributeSet...");
3934         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
3935                                                 getFontFamilyFromAttributeSetMethod,
3936                                                 AttributeSet);
3937         EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to CallObjectMethod()", FALSE);
3938         if (js != (jstring) 0) {
3939             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
3940             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to GetStringChars()", FALSE);
3941             wcsncpy(attributes->fontFamily, stringBytes, (sizeof(attributes->fontFamily) / sizeof(wchar_t)));
3942             length = jniEnv->GetStringLength(js);
3943             attributes->fontFamily[length < (sizeof(attributes->fontFamily) / sizeof(wchar_t)) ?
3944                                    length : (sizeof(attributes->fontFamily) / sizeof(wchar_t))-2] = (wchar_t) 0;
3945             EXCEPTION_CHECK_WITH_RELEASE("Getting FontFamilyFromAttributeSet", FALSE, js, stringBytes);
3946             jniEnv->CallVoidMethod(accessBridgeObject,
3947                                    decrementReferenceMethod, js);
3948             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to CallVoidMethod()", FALSE);
3949             wPrintDebugString(L"[INFO]:   AttributeSet's fontFamily = %ls", attributes->fontFamily);
3950             jniEnv->DeleteLocalRef(js);
3951             EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to DeleteLocalRef()", FALSE);
3952         } else {
3953             PrintDebugString("[WARN]:   AttributeSet's fontFamily is null.");
3954             attributes->backgroundColor[0] = (wchar_t) 0;
3955         }
3956     } else {
3957         PrintDebugString("[ERROR]: either env == 0 or getFontFamilyFromAttributeSetMethod == 0");
3958         jniEnv->CallVoidMethod(accessBridgeObject,
3959                                decrementReferenceMethod, AttributeSet);
3960         EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to CallVoidMethod()", FALSE);
3961         jniEnv->DeleteLocalRef(AttributeSet);
3962         EXCEPTION_CHECK("Getting FontFamilyFromAttributeSet - call to DeleteLocalRef()", FALSE);
3963         return FALSE;
3964     }
3965 
3966     // Get the font size
3967     if (getFontSizeFromAttributeSetMethod != (jmethodID) 0) {
3968         PrintDebugString("[INFO]:  Getting font size from AttributeSet...");
3969         attributes->fontSize = jniEnv->CallIntMethod(accessBridgeObject,
3970                                                      getFontSizeFromAttributeSetMethod,
3971                                                      AttributeSet);
3972         EXCEPTION_CHECK("Getting FontSizeFromAttributeSet - call to CallIntMethod()", FALSE);
3973         PrintDebugString("[INFO]:   AttributeSet's font size = %d", attributes->fontSize);
3974     } else {
3975         PrintDebugString("[ERROR]: either env == 0 or getAlignmentFromAttributeSetMethod == 0");
3976         jniEnv->CallVoidMethod(accessBridgeObject,
3977                                decrementReferenceMethod, AttributeSet);
3978         EXCEPTION_CHECK("Getting FontSizeFromAttributeSet - call to CallVoidMethod()", FALSE);
3979         jniEnv->DeleteLocalRef(AttributeSet);
3980         EXCEPTION_CHECK("Getting FontSizeFromAttributeSet - call to DeleteLocalRef()", FALSE);
3981         return FALSE;
3982     }
3983 
3984 
3985     // Get the alignment setting
3986     if (getAlignmentFromAttributeSetMethod != (jmethodID) 0) {
3987         PrintDebugString(" Getting alignment from AttributeSet...");
3988         attributes->alignment = jniEnv->CallIntMethod(accessBridgeObject,
3989                                                       getAlignmentFromAttributeSetMethod,
3990                                                       AttributeSet);
3991         EXCEPTION_CHECK("Getting AlignmentFromAttributeSet - call to CallIntMethod()", FALSE);
3992     } else {
3993         PrintDebugString("[ERROR]: either env == 0 or getAlignmentFromAttributeSetMethod == 0");
3994         jniEnv->CallVoidMethod(accessBridgeObject,
3995                                decrementReferenceMethod, AttributeSet);
3996         EXCEPTION_CHECK("Getting AlignmentFromAttributeSet - call to CallVoidMethod()", FALSE);
3997         jniEnv->DeleteLocalRef(AttributeSet);
3998         EXCEPTION_CHECK("Getting AlignmentFromAttributeSet - call to DeleteLocalRef()", FALSE);
3999         return FALSE;
4000     }
4001 
4002     // Get the bidiLevel setting
4003     if (getBidiLevelFromAttributeSetMethod != (jmethodID) 0) {
4004         PrintDebugString("[INFO]:  Getting bidiLevel from AttributeSet...");
4005         attributes->bidiLevel = jniEnv->CallIntMethod(accessBridgeObject,
4006                                                       getBidiLevelFromAttributeSetMethod,
4007                                                       AttributeSet);
4008         EXCEPTION_CHECK("Getting BidiLevelFromAttributeSet - call to CallIntMethod()", FALSE);
4009     } else {
4010         PrintDebugString("[ERROR]: either env == 0 or getBidiLevelFromAttributeSetMethod == 0");
4011         jniEnv->CallVoidMethod(accessBridgeObject,
4012                                decrementReferenceMethod, AttributeSet);
4013         EXCEPTION_CHECK("Getting BidiLevelFromAttributeSet - call to CallVoidMethod()", FALSE);
4014         jniEnv->DeleteLocalRef(AttributeSet);
4015         EXCEPTION_CHECK("Getting BidiLevelFromAttributeSet - call to DeleteLocalRef()", FALSE);
4016         return FALSE;
4017     }
4018 
4019     // Get the firstLineIndent setting
4020     if (getFirstLineIndentFromAttributeSetMethod != (jmethodID) 0) {
4021         PrintDebugString("[ERROR]:  Getting firstLineIndent from AttributeSet...");
4022         attributes->firstLineIndent = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject,
4023                                                                        getFirstLineIndentFromAttributeSetMethod,
4024                                                                        AttributeSet);
4025         EXCEPTION_CHECK("Getting FirstLineIndentFromAttributeSet - call to CallIntMethod()", FALSE);
4026     } else {
4027         PrintDebugString("[ERROR]: either env == 0 or getFirstLineIndentFromAttributeSetMethod == 0");
4028         jniEnv->CallVoidMethod(accessBridgeObject,
4029                                decrementReferenceMethod, AttributeSet);
4030         EXCEPTION_CHECK("Getting FirstLineIndentFromAttributeSet - call to CallVoidMethod()", FALSE);
4031         jniEnv->DeleteLocalRef(AttributeSet);
4032         EXCEPTION_CHECK("Getting FirstLineIndentFromAttributeSet - call to DeleteLocalRef()", FALSE);
4033         return FALSE;
4034     }
4035 
4036     // Get the leftIndent setting
4037     if (getLeftIndentFromAttributeSetMethod != (jmethodID) 0) {
4038         PrintDebugString("[INFO]:  Getting leftIndent from AttributeSet...");
4039         attributes->leftIndent = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject,
4040                                                                   getLeftIndentFromAttributeSetMethod,
4041                                                                   AttributeSet);
4042         EXCEPTION_CHECK("Getting LeftIndentFromAttributeSet - call to CallIntMethod()", FALSE);
4043     } else {
4044         PrintDebugString("[ERROR]: either env == 0 or getLeftIndentFromAttributeSetMethod == 0");
4045         jniEnv->CallVoidMethod(accessBridgeObject,
4046                                decrementReferenceMethod, AttributeSet);
4047         EXCEPTION_CHECK("Getting LeftIndentFromAttributeSet - call to CallVoidMethod()", FALSE);
4048         jniEnv->DeleteLocalRef(AttributeSet);
4049         EXCEPTION_CHECK("Getting LeftIndentFromAttributeSet - call to DeleteLocalRef()", FALSE);
4050         return FALSE;
4051     }
4052 
4053     // Get the rightIndent setting
4054     if (getRightIndentFromAttributeSetMethod != (jmethodID) 0) {
4055         PrintDebugString("[INFO]:  Getting rightIndent from AttributeSet...");
4056         attributes->rightIndent = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject,
4057                                                                    getRightIndentFromAttributeSetMethod,
4058                                                                    AttributeSet);
4059         EXCEPTION_CHECK("Getting RightIndentFromAttributeSet - call to CallIntMethod()", FALSE);
4060     } else {
4061         PrintDebugString("[ERROR]: either env == 0 or getRightIndentFromAttributeSetMethod == 0");
4062         jniEnv->CallVoidMethod(accessBridgeObject,
4063                                decrementReferenceMethod, AttributeSet);
4064         EXCEPTION_CHECK("Getting RightIndentFromAttributeSet - call to CallVoidMethod()", FALSE);
4065         jniEnv->DeleteLocalRef(AttributeSet);
4066         EXCEPTION_CHECK("Getting RightIndentFromAttributeSet - call to DeleteLocalRef()", FALSE);
4067         return FALSE;
4068     }
4069 
4070     // Get the lineSpacing setting
4071     if (getLineSpacingFromAttributeSetMethod != (jmethodID) 0) {
4072         PrintDebugString("[INFO]:  Getting lineSpacing from AttributeSet...");
4073         attributes->lineSpacing = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject,
4074                                                                    getLineSpacingFromAttributeSetMethod,
4075                                                                    AttributeSet);
4076         EXCEPTION_CHECK("Getting LineSpacingFromAttributeSet - call to CallIntMethod()", FALSE);
4077     } else {
4078         PrintDebugString("[ERROR]:  either env == 0 or getLineSpacingFromAttributeSetMethod == 0");
4079         jniEnv->CallVoidMethod(accessBridgeObject,
4080                                decrementReferenceMethod, AttributeSet);
4081         EXCEPTION_CHECK("Getting LineSpacingFromAttributeSet - call to CallVoidMethod()", FALSE);
4082         jniEnv->DeleteLocalRef(AttributeSet);
4083         EXCEPTION_CHECK("Getting LineSpacingFromAttributeSet - call to DeleteLocalRef()", FALSE);
4084         return FALSE;
4085     }
4086 
4087     // Get the spaceAbove setting
4088     if (getSpaceAboveFromAttributeSetMethod != (jmethodID) 0) {
4089         PrintDebugString("[INFO]:  Getting spaceAbove from AttributeSet...");
4090         attributes->spaceAbove = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject,
4091                                                                   getSpaceAboveFromAttributeSetMethod,
4092                                                                   AttributeSet);
4093         EXCEPTION_CHECK("Getting SpaceAboveFromAttributeSet - call to CallIntMethod()", FALSE);
4094     } else {
4095         PrintDebugString("[ERROR]:  either env == 0 or getSpaceAboveFromAttributeSetMethod == 0");
4096         jniEnv->CallVoidMethod(accessBridgeObject,
4097                                decrementReferenceMethod, AttributeSet);
4098         EXCEPTION_CHECK("Getting SpaceAboveFromAttributeSet - call to CallVoidMethod()", FALSE);
4099         jniEnv->DeleteLocalRef(AttributeSet);
4100         EXCEPTION_CHECK("Getting SpaceAboveFromAttributeSet - call to DeleteLocalRef()", FALSE);
4101         return FALSE;
4102     }
4103 
4104     // Get the spaceBelow setting
4105     if (getSpaceBelowFromAttributeSetMethod != (jmethodID) 0) {
4106         PrintDebugString("[INFO]:  Getting spaceBelow from AttributeSet...");
4107         attributes->spaceBelow = (jfloat) jniEnv->CallFloatMethod(accessBridgeObject,
4108                                                                   getSpaceBelowFromAttributeSetMethod,
4109                                                                   AttributeSet);
4110         EXCEPTION_CHECK("Getting SpaceBelowFromAttributeSet - call to CallIntMethod()", FALSE);
4111     } else {
4112         PrintDebugString("[ERROR]:  either env == 0 or getSpaceBelowFromAttributeSetMethod == 0");
4113         jniEnv->CallVoidMethod(accessBridgeObject,
4114                                decrementReferenceMethod, AttributeSet);
4115         EXCEPTION_CHECK("Getting SpaceBelowFromAttributeSet - call to CallVoidMethod()", FALSE);
4116         jniEnv->DeleteLocalRef(AttributeSet);
4117         EXCEPTION_CHECK("Getting SpaceBelowFromAttributeSet - call to DeleteLocalRef()", FALSE);
4118         return FALSE;
4119     }
4120 
4121     // Release the AttributeSet object
4122     if (decrementReferenceMethod != (jmethodID) 0) {
4123         PrintDebugString("[INFO]:  Decrementing reference to AttributeSet...");
4124         jniEnv->CallVoidMethod(accessBridgeObject,
4125                                decrementReferenceMethod, AttributeSet);
4126         EXCEPTION_CHECK("Releasing AttributeSet object - call to CallVoidMethod()", FALSE);
4127     } else {
4128         PrintDebugString("[ERROR]:  either env == 0 or accessBridgeObject == 0");
4129         jniEnv->DeleteLocalRef(AttributeSet);
4130         EXCEPTION_CHECK("Releasing AttributeSet object - call to DeleteLocalRef()", FALSE);
4131         return FALSE;
4132     }
4133 
4134     // Get the full attributes string at index
4135     if (getAccessibleAttributesAtIndexFromContextMethod != (jmethodID) 0) {
4136         PrintDebugString("[INFO]:  Getting full attributes string from Context...");
4137         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4138                                                 getAccessibleAttributesAtIndexFromContextMethod,
4139                                                 accessibleContext, index);
4140         EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallObjectMethod()", FALSE);
4141         PrintDebugString("[INFO]:  returned from CallObjectMethod(), js = %p", js);
4142         if (js != (jstring) 0) {
4143             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4144             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to GetStringChars()", FALSE);
4145             wcsncpy(attributes->fullAttributesString, stringBytes, (sizeof(attributes->fullAttributesString) / sizeof(wchar_t)));
4146             length = jniEnv->GetStringLength(js);
4147             attributes->fullAttributesString[length < (sizeof(attributes->fullAttributesString) / sizeof(wchar_t)) ?
4148                                              length : (sizeof(attributes->fullAttributesString) / sizeof(wchar_t))-2] = (wchar_t) 0;
4149             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleAttributesAtIndex", FALSE, js, stringBytes);
4150             jniEnv->CallVoidMethod(accessBridgeObject,
4151                                    decrementReferenceMethod, js);
4152             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to CallVoidMethod()", FALSE);
4153             wPrintDebugString(L"[INFO]:   Accessible Text attributes = %ls", attributes->fullAttributesString);
4154             jniEnv->DeleteLocalRef(js);
4155             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to DeleteLocalRef()", FALSE);
4156         } else {
4157             PrintDebugString("[WARN]:   Accessible Text attributes is null.");
4158             attributes->fullAttributesString[0] = (wchar_t) 0;
4159             jniEnv->DeleteLocalRef(AttributeSet);
4160             EXCEPTION_CHECK("Getting AccessibleAttributesAtIndex - call to DeleteLocalRef()", FALSE);
4161             return FALSE;
4162         }
4163     } else {
4164         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleAttributesAtIndexFromContextMethod == 0");
4165         jniEnv->DeleteLocalRef(AttributeSet);
4166         return FALSE;
4167     }
4168 
4169     jniEnv->DeleteLocalRef(AttributeSet);
4170     EXCEPTION_CHECK("Getting AccessibleAttributeSetAtIndex - call to DeleteLocalRef()", FALSE);
4171     return TRUE;
4172 }
4173 
4174 BOOL
4175 AccessBridgeJavaEntryPoints::getAccessibleTextRect(jobject accessibleContext, AccessibleTextRectInfo *rectInfo, jint index) {
4176 
4177     jthrowable exception;
4178 
4179     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleTextRect(%p), index = %d",
4180                      accessibleContext, index);
4181 
4182     // Verify the Java VM still exists and AccessibleContext is
4183     // an instance of AccessibleText
4184     if (verifyAccessibleText(accessibleContext) == FALSE) {
4185         return FALSE;
4186     }
4187 
4188     // Get the x coord
4189     if (getAccessibleXcoordTextRectAtIndexFromContextMethod != (jmethodID) 0) {
4190         rectInfo->x = jniEnv->CallIntMethod(accessBridgeObject,
4191                                             getAccessibleXcoordTextRectAtIndexFromContextMethod,
4192                                             accessibleContext, index);
4193         EXCEPTION_CHECK("Getting AccessibleXcoordTextRect - call to CallIntMethod()", FALSE);
4194         PrintDebugString("[INFO]:  X coord = %d", rectInfo->x);
4195     } else {
4196         PrintDebugString("[ERROR]: either env == 0 or getAccessibleXcoordTextRectAtIndexFromContextMethod == 0");
4197         return FALSE;
4198     }
4199 
4200     // Get the y coord
4201     if (getAccessibleYcoordTextRectAtIndexFromContextMethod != (jmethodID) 0) {
4202         rectInfo->y = jniEnv->CallIntMethod(accessBridgeObject,
4203                                             getAccessibleYcoordTextRectAtIndexFromContextMethod,
4204                                             accessibleContext, index);
4205         EXCEPTION_CHECK("Getting AccessibleYcoordTextRect - call to CallIntMethod()", FALSE);
4206         PrintDebugString("[INFO]:   Y coord = %d", rectInfo->y);
4207     } else {
4208         PrintDebugString("[INFO]:  either env == 0 or getAccessibleYcoordTextRectAtIndexFromContextMethod == 0");
4209         return FALSE;
4210     }
4211 
4212     // Get the width
4213     if (getAccessibleWidthTextRectAtIndexFromContextMethod != (jmethodID) 0) {
4214         rectInfo->width = jniEnv->CallIntMethod(accessBridgeObject,
4215                                                 getAccessibleWidthTextRectAtIndexFromContextMethod,
4216                                                 accessibleContext, index);
4217         EXCEPTION_CHECK("Getting AccessibleWidthTextRect - call to CallIntMethod()", FALSE);
4218         PrintDebugString("[INFO]: Width = %d", rectInfo->width);
4219     } else {
4220         PrintDebugString("[INFO]: either env == 0 or getAccessibleWidthTextRectAtIndexFromContextMethod == 0");
4221         return FALSE;
4222     }
4223 
4224     // Get the height
4225     if (getAccessibleHeightTextRectAtIndexFromContextMethod != (jmethodID) 0) {
4226         rectInfo->height = jniEnv->CallIntMethod(accessBridgeObject,
4227                                                  getAccessibleHeightTextRectAtIndexFromContextMethod,
4228                                                  accessibleContext, index);
4229         EXCEPTION_CHECK("Getting AccessibleHeightTextRect - call to CallIntMethod()", FALSE);
4230         PrintDebugString("[INFO]: Height = %d", rectInfo->height);
4231     } else {
4232         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleHeightTextRectAtIndexFromContextMethod == 0");
4233         return FALSE;
4234     }
4235 
4236     return TRUE;
4237 }
4238 
4239 // =====
4240 
4241 /**
4242  * gets the bounding rectangle for the text caret
4243  */
4244 BOOL
4245 AccessBridgeJavaEntryPoints::getCaretLocation(jobject accessibleContext, AccessibleTextRectInfo *rectInfo, jint index) {
4246 
4247     jthrowable exception;
4248 
4249     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getCaretLocation(%p), index = %d",
4250                      accessibleContext, index);
4251 
4252     // Verify the Java VM still exists and AccessibleContext is
4253     // an instance of AccessibleText
4254     if (verifyAccessibleText(accessibleContext) == FALSE) {
4255         return FALSE;
4256     }
4257 
4258     // Get the x coord
4259     if (getCaretLocationXMethod != (jmethodID) 0) {
4260         rectInfo->x = jniEnv->CallIntMethod(accessBridgeObject,
4261                                             getCaretLocationXMethod,
4262                                             accessibleContext, index);
4263         EXCEPTION_CHECK("Getting caret X coordinate - call to CallIntMethod()", FALSE);
4264         PrintDebugString("[INFO]:   X coord = %d", rectInfo->x);
4265     } else {
4266         PrintDebugString("[ERROR]:  either env == 0 or getCaretLocationXMethod == 0");
4267         return FALSE;
4268     }
4269 
4270     // Get the y coord
4271     if (getCaretLocationYMethod != (jmethodID) 0) {
4272         rectInfo->y = jniEnv->CallIntMethod(accessBridgeObject,
4273                                             getCaretLocationYMethod,
4274                                             accessibleContext, index);
4275         EXCEPTION_CHECK("Getting caret Y coordinate - call to CallIntMethod()", FALSE);
4276         PrintDebugString("[INFO]:   Y coord = %d", rectInfo->y);
4277     } else {
4278         PrintDebugString("[ERROR]:  either env == 0 or getCaretLocationYMethod == 0");
4279         return FALSE;
4280     }
4281 
4282     // Get the width
4283     if (getCaretLocationWidthMethod != (jmethodID) 0) {
4284         rectInfo->width = jniEnv->CallIntMethod(accessBridgeObject,
4285                                                 getCaretLocationWidthMethod,
4286                                                 accessibleContext, index);
4287         EXCEPTION_CHECK("Getting caret width - call to CallIntMethod()", FALSE);
4288         PrintDebugString("[INFO]:   Width = %d", rectInfo->width);
4289     } else {
4290         PrintDebugString("[ERROR]:  either env == 0 or getCaretLocationWidthMethod == 0");
4291         return FALSE;
4292     }
4293 
4294     // Get the height
4295     if (getCaretLocationHeightMethod != (jmethodID) 0) {
4296         rectInfo->height = jniEnv->CallIntMethod(accessBridgeObject,
4297                                                  getCaretLocationHeightMethod,
4298                                                  accessibleContext, index);
4299         EXCEPTION_CHECK("Getting caret height - call to CallIntMethod()", FALSE);
4300         PrintDebugString("[INFO]:   Height = %d", rectInfo->height);
4301     } else {
4302         PrintDebugString("[ERROR]:  either env == 0 or getCaretLocationHeightMethod == 0");
4303         return FALSE;
4304     }
4305 
4306     return TRUE;
4307 }
4308 
4309 // =====
4310 
4311 BOOL
4312 AccessBridgeJavaEntryPoints::getAccessibleTextLineBounds(jobject accessibleContext, jint index, jint *startIndex, jint *endIndex) {
4313 
4314     jthrowable exception;
4315 
4316     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleTextLineBounds(%p):", accessibleContext);
4317 
4318     // Verify the Java VM still exists and AccessibleContext is
4319     // an instance of AccessibleText
4320     if (verifyAccessibleText(accessibleContext) == FALSE) {
4321         return FALSE;
4322     }
4323 
4324     // Get the index of the left boundary of the line containing 'index'
4325     if (getAccessibleTextLineLeftBoundsFromContextMethod != (jmethodID) 0) {
4326         *startIndex = jniEnv->CallIntMethod(accessBridgeObject,
4327                                             getAccessibleTextLineLeftBoundsFromContextMethod,
4328                                             accessibleContext, index);
4329         EXCEPTION_CHECK("Getting AccessibleTextLineLeftBounds - call to CallIntMethod()", FALSE);
4330         PrintDebugString("[INFO]:   startIndex = %d", *startIndex);
4331     } else {
4332         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleTextLineLeftBoundsFromContextMethod == 0");
4333         return FALSE;
4334     }
4335 
4336     // Get the index of the right boundary of the line containing 'index'
4337     if (getAccessibleTextLineRightBoundsFromContextMethod != (jmethodID) 0) {
4338         *endIndex = jniEnv->CallIntMethod(accessBridgeObject,
4339                                           getAccessibleTextLineRightBoundsFromContextMethod,
4340                                           accessibleContext, index);
4341         EXCEPTION_CHECK("Getting AccessibleTextLineRightBounds - call to CallIntMethod()", FALSE);
4342         PrintDebugString("[INFO]:   endIndex = %d", *endIndex);
4343     } else {
4344         PrintDebugString("[ERROR]:  either env == 0 or getAccessibleTextLineRightBoundsFromContextMethod == 0");
4345         return FALSE;
4346     }
4347 
4348     return TRUE;
4349 }
4350 
4351 BOOL
4352 AccessBridgeJavaEntryPoints::getAccessibleTextRange(jobject accessibleContext,
4353                                                     jint start, jint end, wchar_t *text, short len) {
4354     jstring js;
4355     const wchar_t *stringBytes;
4356     jthrowable exception;
4357     jsize length;
4358 
4359     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleTextRange(%p, %d, %d, *text, %d):", accessibleContext, start, end, len);
4360 
4361     // Verify the Java VM still exists and AccessibleContext is
4362     // an instance of AccessibleText
4363     if (verifyAccessibleText(accessibleContext) == FALSE) {
4364         return FALSE;
4365     }
4366 
4367     // range is inclusive
4368     if (end < start) {
4369         PrintDebugString("[ERROR]:  end < start!");
4370         text[0] = (wchar_t) 0;
4371         return FALSE;
4372     }
4373 
4374     // Get the text range within [start, end] inclusive
4375     if (getAccessibleTextRangeFromContextMethod != (jmethodID) 0) {
4376         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4377                                                 getAccessibleTextRangeFromContextMethod,
4378                                                 accessibleContext, start, end);
4379         EXCEPTION_CHECK("Getting AccessibleTextRange - call to CallObjectMethod()", FALSE);
4380         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
4381         if (js != (jstring) 0) {
4382             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4383             EXCEPTION_CHECK("Getting AccessibleTextRange - call to GetStringChars()", FALSE);
4384             wPrintDebugString(L"[INFO]:   Accessible Text stringBytes returned from Java = %ls", stringBytes);
4385             wcsncpy(text, stringBytes, len);
4386             length = jniEnv->GetStringLength(js);
4387             PrintDebugString("[INFO]:  Accessible Text stringBytes length = %d", length);
4388             text[length < len ? length : len - 2] = (wchar_t) 0;
4389             wPrintDebugString(L"[INFO]:   Accessible Text 'text' after null termination = %ls", text);
4390             EXCEPTION_CHECK_WITH_RELEASE("Getting AccessibleTextRange", FALSE, js, stringBytes);
4391             jniEnv->CallVoidMethod(accessBridgeObject,
4392                                    decrementReferenceMethod, js);
4393             EXCEPTION_CHECK("Getting AccessibleTextRange - call to CallVoidMethod()", FALSE);
4394             wPrintDebugString(L"[INFO]:   Accessible Text range = %ls", text);
4395             jniEnv->DeleteLocalRef(js);
4396             EXCEPTION_CHECK("Getting AccessibleTextRange - call to DeleteLocalRef()", FALSE);
4397         } else {
4398             PrintDebugString("[WARN]:   current Accessible Text range is null.");
4399             text[0] = (wchar_t) 0;
4400             return FALSE;
4401         }
4402     } else {
4403         PrintDebugString("[ERROR]: either env == 0 or getAccessibleTextRangeFromContextMethod == 0");
4404         return FALSE;
4405     }
4406     return TRUE;
4407 }
4408 
4409 /********** AccessibleValue routines ***************/
4410 
4411 BOOL
4412 AccessBridgeJavaEntryPoints::getCurrentAccessibleValueFromContext(jobject accessibleContext, wchar_t *value, short len) {
4413     jstring js;
4414     const wchar_t *stringBytes;
4415     jthrowable exception;
4416     jsize length;
4417 
4418     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getCurrentAccessibleValueFromContext(%p):", accessibleContext);
4419 
4420     // Get the current Accessible Value
4421     if (getCurrentAccessibleValueFromContextMethod != (jmethodID) 0) {
4422         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4423                                                 getCurrentAccessibleValueFromContextMethod,
4424                                                 accessibleContext);
4425         EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to CallObjectMethod()", FALSE);
4426         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
4427         if (js != (jstring) 0) {
4428             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4429             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to GetStringChars()", FALSE);
4430             wcsncpy(value, stringBytes, len);
4431             length = jniEnv->GetStringLength(js);
4432             value[length < len ? length : len - 2] = (wchar_t) 0;
4433             EXCEPTION_CHECK_WITH_RELEASE("Getting CurrentAccessibleValue", FALSE, js, stringBytes);
4434             jniEnv->CallVoidMethod(accessBridgeObject,
4435                                    decrementReferenceMethod, js);
4436             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to CallVoidMethod()", FALSE);
4437             PrintDebugString("[INFO]:   current Accessible Value = %s", value);
4438             jniEnv->DeleteLocalRef(js);
4439             EXCEPTION_CHECK("Getting CurrentAccessibleValue - call to DeleteLocalRef()", FALSE);
4440         } else {
4441             PrintDebugString("[WARN]:   current Accessible Value is null.");
4442             value[0] = (wchar_t) 0;
4443             return FALSE;
4444         }
4445     } else {
4446         PrintDebugString("[ERROR]:  either env == 0 or getCurrentAccessibleValueFromContextMethod == 0");
4447         return FALSE;
4448     }
4449     return TRUE;
4450 }
4451 
4452 BOOL
4453 AccessBridgeJavaEntryPoints::getMaximumAccessibleValueFromContext(jobject accessibleContext, wchar_t *value, short len) {
4454     jstring js;
4455     const wchar_t *stringBytes;
4456     jthrowable exception;
4457     jsize length;
4458 
4459     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getMaximumAccessibleValueFromContext(%p):", accessibleContext);
4460 
4461     // Get the maximum Accessible Value
4462     if (getMaximumAccessibleValueFromContextMethod != (jmethodID) 0) {
4463         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4464                                                 getMaximumAccessibleValueFromContextMethod,
4465                                                 accessibleContext);
4466         EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to CallObjectMethod()", FALSE);
4467         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
4468         if (js != (jstring) 0) {
4469             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4470             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to GetStringChars()", FALSE);
4471             wcsncpy(value, stringBytes, len);
4472             length = jniEnv->GetStringLength(js);
4473             value[length < len ? length : len - 2] = (wchar_t) 0;
4474             EXCEPTION_CHECK_WITH_RELEASE("Getting MaximumAccessibleValue", FALSE, js, stringBytes);
4475             jniEnv->CallVoidMethod(accessBridgeObject,
4476                                    decrementReferenceMethod, js);
4477             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to CallVoidMethod()", FALSE);
4478             PrintDebugString("[INFO]:   maximum Accessible Value = %s", value);
4479             jniEnv->DeleteLocalRef(js);
4480             EXCEPTION_CHECK("Getting MaximumAccessibleValue - call to DeleteLocalRef()", FALSE);
4481         } else {
4482             PrintDebugString("[WARN]:   maximum Accessible Value is null.");
4483             value[0] = (wchar_t) 0;
4484             return FALSE;
4485         }
4486     } else {
4487         PrintDebugString("[ERROR]: either env == 0 or getMaximumAccessibleValueFromContextMethod == 0");
4488         return FALSE;
4489     }
4490     return TRUE;
4491 }
4492 
4493 BOOL
4494 AccessBridgeJavaEntryPoints::getMinimumAccessibleValueFromContext(jobject accessibleContext, wchar_t *value, short len) {
4495     jstring js;
4496     const wchar_t *stringBytes;
4497     jthrowable exception;
4498     jsize length;
4499 
4500     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getMinimumAccessibleValueFromContext(%p):", accessibleContext);
4501 
4502     // Get the mimimum Accessible Value
4503     if (getMinimumAccessibleValueFromContextMethod != (jmethodID) 0) {
4504         js = (jstring) jniEnv->CallObjectMethod(accessBridgeObject,
4505                                                 getMinimumAccessibleValueFromContextMethod,
4506                                                 accessibleContext);
4507         EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to CallObjectMethod()", FALSE);
4508         PrintDebugString("[INFO]:   returned from CallObjectMethod(), js = %p", js);
4509         if (js != (jstring) 0) {
4510             stringBytes = (const wchar_t *) jniEnv->GetStringChars(js, 0);
4511             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to GetStringChars()", FALSE);
4512             wcsncpy(value, stringBytes, len);
4513             length = jniEnv->GetStringLength(js);
4514             value[length < len ? length : len - 2] = (wchar_t) 0;
4515             EXCEPTION_CHECK_WITH_RELEASE("Getting MinimumAccessibleValue", FALSE, js, stringBytes);
4516             jniEnv->CallVoidMethod(accessBridgeObject,
4517                                    decrementReferenceMethod, js);
4518             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to CallVoidMethod()", FALSE);
4519             PrintDebugString("[INFO]:   mimimum Accessible Value = %s", value);
4520             jniEnv->DeleteLocalRef(js);
4521             EXCEPTION_CHECK("Getting MinimumAccessibleValue - call to DeleteLocalRef()", FALSE);
4522         } else {
4523             PrintDebugString("[WARN]:   mimimum Accessible Value is null.");
4524             value[0] = (wchar_t) 0;
4525             return FALSE;
4526         }
4527     } else {
4528         PrintDebugString("[ERROR]: either env == 0 or getMinimumAccessibleValueFromContextMethod == 0");
4529         return FALSE;
4530     }
4531     return TRUE;
4532 }
4533 
4534 
4535 /********** AccessibleSelection routines ***************/
4536 
4537 void
4538 AccessBridgeJavaEntryPoints::addAccessibleSelectionFromContext(jobject accessibleContext, int i) {
4539     jthrowable exception;
4540 
4541     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::addAccessibleSelectionFromContext(%p):", accessibleContext);
4542 
4543     // Add the child to the AccessibleSelection
4544     if (addAccessibleSelectionFromContextMethod != (jmethodID) 0) {
4545         jniEnv->CallVoidMethod(accessBridgeObject,
4546                                addAccessibleSelectionFromContextMethod,
4547                                accessibleContext, i);
4548         EXCEPTION_CHECK_VOID("Doing addAccessibleSelection - call to CallVoidMethod()");
4549         PrintDebugString("[INFO]:   returned from CallObjectMethod()");
4550     } else {
4551         PrintDebugString("[ERROR]:  either env == 0 or addAccessibleSelectionFromContextMethod == 0");
4552     }
4553 }
4554 
4555 void
4556 AccessBridgeJavaEntryPoints::clearAccessibleSelectionFromContext(jobject accessibleContext) {
4557     jthrowable exception;
4558 
4559     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::clearAccessibleSelectionFromContext(%p):", accessibleContext);
4560 
4561     // Clearing the Selection of the AccessibleSelection
4562     if (clearAccessibleSelectionFromContextMethod != (jmethodID) 0) {
4563         jniEnv->CallVoidMethod(accessBridgeObject,
4564                                clearAccessibleSelectionFromContextMethod,
4565                                accessibleContext);
4566         EXCEPTION_CHECK_VOID("Doing clearAccessibleSelection - call to CallVoidMethod()");
4567         PrintDebugString("[INFO]:   returned from CallObjectMethod()");
4568     } else {
4569         PrintDebugString("[ERROR]:  either env == 0 or clearAccessibleSelectionFromContextMethod == 0");
4570     }
4571 }
4572 
4573 jobject
4574 AccessBridgeJavaEntryPoints::getAccessibleSelectionFromContext(jobject accessibleContext, int i) {
4575     jobject returnedAccessibleContext;
4576     jobject globalRef;
4577     jthrowable exception;
4578 
4579     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleSelectionFromContext(%p):", accessibleContext);
4580 
4581     if (getAccessibleSelectionContextFromContextMethod != (jmethodID) 0) {
4582         returnedAccessibleContext = jniEnv->CallObjectMethod(
4583                                                              accessBridgeObject,
4584                                                              getAccessibleSelectionContextFromContextMethod,
4585                                                              accessibleContext, i);
4586         EXCEPTION_CHECK("Getting AccessibleSelectionContext - call to CallObjectMethod()", (jobject) 0);
4587         globalRef = jniEnv->NewGlobalRef(returnedAccessibleContext);
4588         EXCEPTION_CHECK("Getting AccessibleSelectionContext - call to NewGlobalRef()", (jobject) 0);
4589         jniEnv->DeleteLocalRef(returnedAccessibleContext);
4590         EXCEPTION_CHECK("Getting AccessibleSelectionContext - call to DeleteLocalRef()", (jobject) 0);
4591         PrintDebugString("[INFO]:   Returning - returnedAccessibleContext = %p; globalRef = %p",
4592                          returnedAccessibleContext, globalRef);
4593         return globalRef;
4594     } else {
4595         PrintDebugString("[ERROR]: either env == 0 or getAccessibleSelectionContextFromContextMethod == 0");
4596         return (jobject) 0;
4597     }
4598 }
4599 
4600 int
4601 AccessBridgeJavaEntryPoints::getAccessibleSelectionCountFromContext(jobject accessibleContext) {
4602     int count;
4603     jthrowable exception;
4604 
4605     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::getAccessibleSelectionCountFromContext(%p):", accessibleContext);
4606 
4607     // Get (& return) the # of items selected in the AccessibleSelection
4608     if (getAccessibleSelectionCountFromContextMethod != (jmethodID) 0) {
4609         count = jniEnv->CallIntMethod(accessBridgeObject,
4610                                       getAccessibleSelectionCountFromContextMethod,
4611                                       accessibleContext);
4612         EXCEPTION_CHECK("Getting AccessibleSelectionCount - call to CallIntMethod()", -1);
4613         PrintDebugString("[INFO]:   returned from CallObjectMethod()");
4614         return count;
4615     } else {
4616         PrintDebugString("[ERROR]: either env == 0 or getAccessibleSelectionCountFromContextMethod == 0");
4617         return -1;
4618     }
4619 }
4620 
4621 BOOL
4622 AccessBridgeJavaEntryPoints::isAccessibleChildSelectedFromContext(jobject accessibleContext, int i) {
4623     jboolean result;
4624     jthrowable exception;
4625 
4626     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::isAccessibleChildSelectedFromContext(%p):", accessibleContext);
4627 
4628     // Get (& return) the # of items selected in the AccessibleSelection
4629     if (isAccessibleChildSelectedFromContextMethod != (jmethodID) 0) {
4630         result = jniEnv->CallBooleanMethod(accessBridgeObject,
4631                                            isAccessibleChildSelectedFromContextMethod,
4632                                            accessibleContext, i);
4633         EXCEPTION_CHECK("Doing isAccessibleChildSelected - call to CallBooleanMethod()", FALSE);
4634         PrintDebugString("[INFO]:   returned from CallObjectMethod()");
4635         if (result != 0) {
4636             return TRUE;
4637         }
4638     } else {
4639         PrintDebugString("[ERROR]: either env == 0 or isAccessibleChildSelectedFromContextMethod == 0");
4640     }
4641     return FALSE;
4642 }
4643 
4644 
4645 void
4646 AccessBridgeJavaEntryPoints::removeAccessibleSelectionFromContext(jobject accessibleContext, int i) {
4647     jthrowable exception;
4648 
4649     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::removeAccessibleSelectionFromContext(%p):", accessibleContext);
4650 
4651     // Remove the i-th child from the AccessibleSelection
4652     if (removeAccessibleSelectionFromContextMethod != (jmethodID) 0) {
4653         jniEnv->CallVoidMethod(accessBridgeObject,
4654                                removeAccessibleSelectionFromContextMethod,
4655                                accessibleContext, i);
4656         EXCEPTION_CHECK_VOID("Doing removeAccessibleSelection - call to CallVoidMethod()");
4657         PrintDebugString("[INFO]:   returned from CallObjectMethod()");
4658     } else {
4659         PrintDebugString("[ERROR]:  either env == 0 or removeAccessibleSelectionFromContextMethod == 0");
4660     }
4661 }
4662 
4663 void
4664 AccessBridgeJavaEntryPoints::selectAllAccessibleSelectionFromContext(jobject accessibleContext) {
4665     jthrowable exception;
4666 
4667     PrintDebugString("[INFO]: Calling AccessBridgeJavaEntryPoints::selectAllAccessibleSelectionFromContext(%p):", accessibleContext);
4668 
4669     // Select all children (if possible) of the AccessibleSelection
4670     if (selectAllAccessibleSelectionFromContextMethod != (jmethodID) 0) {
4671         jniEnv->CallVoidMethod(accessBridgeObject,
4672                                selectAllAccessibleSelectionFromContextMethod,
4673                                accessibleContext);
4674         EXCEPTION_CHECK_VOID("Doing selectAllAccessibleSelection - call to CallVoidMethod()");
4675         PrintDebugString("[INFO]:   returned from CallObjectMethod()");
4676     } else {
4677         PrintDebugString("[ERROR]: either env == 0 or selectAllAccessibleSelectionFromContextMethod == 0");
4678     }
4679 }
4680 
4681 
4682 /********** Event Notification Registration routines ***************/
4683 
4684 BOOL
4685 AccessBridgeJavaEntryPoints::addJavaEventNotification(jlong type) {
4686     jthrowable exception;
4687 
4688     PrintDebugString("[INFO]:   in AccessBridgeJavaEntryPoints::addJavaEventNotification(%016I64X);", type);
4689 
4690     // Let AccessBridge know we want to add an event type
4691     if (addJavaEventNotificationMethod != (jmethodID) 0) {
4692         jniEnv->CallVoidMethod(accessBridgeObject,
4693                                addJavaEventNotificationMethod, type);
4694         EXCEPTION_CHECK("Doing addJavaEventNotification - call to CallVoidMethod()", FALSE);
4695     } else {
4696         PrintDebugString("[ERROR]: either env == 0 or addJavaEventNotificationMethod == 0");
4697         return FALSE;
4698     }
4699     return TRUE;
4700 }
4701 
4702 BOOL
4703 AccessBridgeJavaEntryPoints::removeJavaEventNotification(jlong type) {
4704     jthrowable exception;
4705 
4706     PrintDebugString("[INFO]:  in AccessBridgeJavaEntryPoints::removeJavaEventNotification(%016I64X):", type);
4707 
4708     // Let AccessBridge know we want to remove an event type
4709     if (removeJavaEventNotificationMethod != (jmethodID) 0) {
4710         jniEnv->CallVoidMethod(accessBridgeObject,
4711                                removeJavaEventNotificationMethod, type);
4712         EXCEPTION_CHECK("Doing removeJavaEventNotification - call to CallVoidMethod()", FALSE);
4713     } else {
4714         PrintDebugString("[ERROR]: either env == 0 or removeJavaEventNotificationMethod == 0");
4715         return FALSE;
4716     }
4717     return TRUE;
4718 }
4719 
4720 BOOL
4721 AccessBridgeJavaEntryPoints::addAccessibilityEventNotification(jlong type) {
4722     jthrowable exception;
4723 
4724     PrintDebugString("[INFO]:   in AccessBridgeJavaEntryPoints::addAccessibilityEventNotification(%016I64X);", type);
4725 
4726     // Let AccessBridge know we want to add an event type
4727     if (addAccessibilityEventNotificationMethod != (jmethodID) 0) {
4728         PrintDebugString("[INFO]:    addAccessibilityEventNotification: calling void method: accessBridgeObject = %p", accessBridgeObject);
4729         jniEnv->CallVoidMethod(accessBridgeObject,
4730                                addAccessibilityEventNotificationMethod, type);
4731         EXCEPTION_CHECK("Doing addAccessibilityEvent - call to CallVoidMethod()", FALSE);
4732     } else {
4733         PrintDebugString("[ERROR]: either env == 0 or addAccessibilityEventNotificationMethod == 0");
4734         return FALSE;
4735     }
4736     PrintDebugString("[INFO]:     addAccessibilityEventNotification: just returning true");
4737     return TRUE;
4738 }
4739 
4740 BOOL
4741 AccessBridgeJavaEntryPoints::removeAccessibilityEventNotification(jlong type) {
4742     jthrowable exception;
4743 
4744     PrintDebugString("[INFO]:  in AccessBridgeJavaEntryPoints::removeAccessibilityEventNotification(%016I64X):", type);
4745 
4746     // Let AccessBridge know we want to remove an event type
4747     if (removeAccessibilityEventNotificationMethod != (jmethodID) 0) {
4748         jniEnv->CallVoidMethod(accessBridgeObject,
4749                                removeAccessibilityEventNotificationMethod, type);
4750         EXCEPTION_CHECK("Doing removeAccessibilityEvent - call to CallVoidMethod()", FALSE);
4751     } else {
4752         PrintDebugString("[ERROR]: either env == 0 or removeAccessibilityEventNotificationMethod == 0");
4753         return FALSE;
4754     }
4755     return TRUE;
4756 }