changeset 6840:0bd76d001286

[Accessibility] Improving handling of exceptions in GlassAccessible.cpp
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Mon, 21 Apr 2014 17:00:35 -0700
parents e466fb7619f2
children e44ae258c6db
files modules/graphics/src/main/native-glass/win/GlassAccessible.cpp modules/graphics/src/main/native-glass/win/GlassAccessible.h
diffstat 2 files changed, 97 insertions(+), 100 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/native-glass/win/GlassAccessible.cpp	Mon Apr 21 15:30:22 2014 -0700
+++ b/modules/graphics/src/main/native-glass/win/GlassAccessible.cpp	Mon Apr 21 17:00:35 2014 -0700
@@ -218,31 +218,29 @@
     return hr;
 }
 
-jlong GlassAccessible::callLongMethod(jmethodID mid, ...)
+HRESULT GlassAccessible::callLongMethod(jmethodID mid,  IUnknown **pRetVal, ...)
 {
     va_list vl;
     va_start(vl, mid);
     JNIEnv* env = GetEnv();
     jlong ptr = env->CallLongMethodV(m_jAccessible, mid, vl);
-    CheckAndClearException(env);
     va_end(vl);
+    if (CheckAndClearException(env)) return E_FAIL;
 
     /* AddRef the result */
     IUnknown* iUnknown = reinterpret_cast<IUnknown*>(ptr);
     if (iUnknown) iUnknown->AddRef();
-
-    return ptr;
+    *pRetVal = iUnknown;
+    return S_OK;
 }
 
-SAFEARRAY* GlassAccessible::callArrayMethod(jmethodID mid, VARTYPE vt)
+HRESULT GlassAccessible::callArrayMethod(jmethodID mid, VARTYPE vt, SAFEARRAY **pRetVal)
 {
     JNIEnv* env = GetEnv();
     jarray list = (jarray)env->CallObjectMethod(m_jAccessible, mid);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
 
-    SAFEARRAY *psa=NULL;
-    GlassAccessible::copyList(env, list, &psa, vt);
-    return psa;
+    return GlassAccessible::copyList(env, list, pRetVal, vt);
 }
 
 GlassAccessible::GlassAccessible(JNIEnv* env, jobject jAccessible)
@@ -331,7 +329,7 @@
     if (pRetVal == NULL) return E_INVALIDARG;
     JNIEnv* env = GetEnv();
     jlong hwnd = env->CallLongMethod(m_jAccessible, mid_get_HostRawElementProvider);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     
     // We ignore the return value of UiaHostProviderFromHwnd because it returns E_INVALIDARG
     // when invoked with NULL hwnd. We use NULL hwnds to represent "lightweight" accessibles.
@@ -356,9 +354,7 @@
 IFACEMETHODIMP GlassAccessible::GetPatternProvider(PATTERNID patternId, IUnknown** pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    jlong ptr = callLongMethod(mid_GetPatternProvider, patternId);
-    *pRetVal = reinterpret_cast<IUnknown*>(ptr);
-    return S_OK;
+    return callLongMethod(mid_GetPatternProvider, pRetVal, patternId);
 }
 
 IFACEMETHODIMP GlassAccessible::GetPropertyValue(PROPERTYID propertyId, VARIANT* pRetVal)
@@ -366,10 +362,9 @@
     if (pRetVal == NULL) return E_INVALIDARG;
     JNIEnv* env = GetEnv();
     jobject jVariant = env->CallObjectMethod(m_jAccessible, mid_GetPropertyValue, propertyId);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
 
-    copyVariant(env, jVariant, pRetVal);
-    return S_OK;
+    return copyVariant(env, jVariant, pRetVal);
 }
 
 /***********************************************/
@@ -380,7 +375,7 @@
     if (pRetVal == NULL) return E_INVALIDARG;
     JNIEnv* env = GetEnv();
     jfloatArray bounds = (jfloatArray)env->CallObjectMethod(m_jAccessible, mid_get_BoundingRectangle);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
 
     if (bounds) {
         jfloat* boundsPtr = (jfloat*)env->GetPrimitiveArrayCritical(bounds, 0);
@@ -396,38 +391,38 @@
 IFACEMETHODIMP GlassAccessible::get_FragmentRoot(IRawElementProviderFragmentRoot **pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    jlong ptr = callLongMethod(mid_get_FragmentRoot);
+    IUnknown* ptr = NULL;
+    HRESULT hr = callLongMethod(mid_get_FragmentRoot, &ptr);
     *pRetVal = reinterpret_cast<IRawElementProviderFragmentRoot*>(ptr);
-    return S_OK;
+    return hr;
 }
 
 IFACEMETHODIMP GlassAccessible::GetEmbeddedFragmentRoots(SAFEARRAY **pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    *pRetVal = callArrayMethod(mid_GetEmbeddedFragmentRoots, VT_UNKNOWN);
-    return S_OK;
+    return callArrayMethod(mid_GetEmbeddedFragmentRoots, VT_UNKNOWN, pRetVal);
 }
 
 IFACEMETHODIMP GlassAccessible::GetRuntimeId(SAFEARRAY **pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    *pRetVal = callArrayMethod(mid_GetRuntimeId, VT_I4);
-    return S_OK;
+    return callArrayMethod(mid_GetRuntimeId, VT_I4, pRetVal);
 }
 
 IFACEMETHODIMP GlassAccessible::Navigate(NavigateDirection direction, IRawElementProviderFragment **pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    jlong ptr = callLongMethod(mid_Navigate, direction);
+    IUnknown* ptr = NULL;
+    HRESULT hr = callLongMethod(mid_Navigate, &ptr, direction);
     *pRetVal = reinterpret_cast<IRawElementProviderFragment*>(ptr);
-    return S_OK;
+    return hr;
 }
 
 IFACEMETHODIMP GlassAccessible::SetFocus()
 {
     JNIEnv* env = GetEnv();
     env->CallVoidMethod(m_jAccessible, mid_SetFocus);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -437,17 +432,19 @@
 IFACEMETHODIMP GlassAccessible::ElementProviderFromPoint(double x, double y, IRawElementProviderFragment **pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    jlong ptr = callLongMethod(mid_ElementProviderFromPoint, x, y);
+    IUnknown* ptr = NULL;
+    HRESULT hr = callLongMethod(mid_ElementProviderFromPoint, &ptr, x, y);
     *pRetVal = reinterpret_cast<IRawElementProviderFragment*>(ptr);
-    return S_OK;
+    return hr;
 }
 
 IFACEMETHODIMP GlassAccessible::GetFocus(IRawElementProviderFragment **pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    jlong ptr = callLongMethod(mid_GetFocus);
+    IUnknown* ptr = NULL;
+    HRESULT hr = callLongMethod(mid_GetFocus, &ptr);
     *pRetVal = reinterpret_cast<IRawElementProviderFragment*>(ptr);
-    return S_OK;
+    return hr;
 }
 
 /***********************************************/
@@ -457,7 +454,7 @@
 {
     JNIEnv* env = GetEnv();
     env->CallVoidMethod(m_jAccessible, mid_Invoke);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -467,15 +464,14 @@
 IFACEMETHODIMP GlassAccessible::GetSelection(SAFEARRAY **pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    *pRetVal = callArrayMethod(mid_GetSelection, VT_UNKNOWN);
-    return S_OK;
+    return callArrayMethod(mid_GetSelection, VT_UNKNOWN, pRetVal);
 }
 
 IFACEMETHODIMP GlassAccessible::get_CanSelectMultiple(BOOL *pRetVal)
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallBooleanMethod(m_jAccessible, mid_get_CanSelectMultiple);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -483,7 +479,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallBooleanMethod(m_jAccessible, mid_get_IsSelectionRequired);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -494,7 +490,7 @@
 {
     JNIEnv* env = GetEnv();
     env->CallVoidMethod(m_jAccessible, mid_Select);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -502,7 +498,7 @@
 {
     JNIEnv* env = GetEnv();
     env->CallVoidMethod(m_jAccessible, mid_AddToSelection);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -510,7 +506,7 @@
 {
     JNIEnv* env = GetEnv();
     env->CallVoidMethod(m_jAccessible, mid_RemoveFromSelection);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -518,16 +514,17 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallBooleanMethod(m_jAccessible, mid_get_IsSelected);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
 IFACEMETHODIMP GlassAccessible::get_SelectionContainer(IRawElementProviderSimple **pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    jlong ptr = callLongMethod(mid_get_SelectionContainer);
+    IUnknown* ptr = NULL;
+    HRESULT hr = callLongMethod(mid_get_SelectionContainer, &ptr);
     *pRetVal = reinterpret_cast<IRawElementProviderSimple*>(ptr);
-    return S_OK;
+    return hr;
 }
 
 /***********************************************/
@@ -537,7 +534,7 @@
 {
     JNIEnv* env = GetEnv();
     env->CallVoidMethod(m_jAccessible, mid_SetValue, val);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -545,7 +542,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallDoubleMethod(m_jAccessible, mid_get_Value);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -553,7 +550,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallBooleanMethod(m_jAccessible, mid_get_IsReadOnly);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -561,7 +558,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallDoubleMethod(m_jAccessible, mid_get_Maximum);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -569,7 +566,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallDoubleMethod(m_jAccessible, mid_get_Minimum);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -577,7 +574,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallDoubleMethod(m_jAccessible, mid_get_LargeChange);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -585,7 +582,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallDoubleMethod(m_jAccessible, mid_get_SmallChange);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -600,7 +597,7 @@
     jstring str = env->NewString((const jchar *)val, (jsize)size);
     if (!CheckAndClearException(env)) {
     	env->CallVoidMethod(m_jAccessible, mid_SetValueString, str);
-    	CheckAndClearException(env);
+    	if (CheckAndClearException(env)) return E_FAIL;
     }
     return S_OK;
 }
@@ -609,7 +606,7 @@
 {
     JNIEnv* env = GetEnv();
     jstring str = (jstring)env->CallObjectMethod(m_jAccessible, mid_get_ValueString);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     if (str) {
         UINT length = env->GetStringLength(str);
         const jchar* ptr = env->GetStringCritical(str, NULL);
@@ -629,39 +626,41 @@
 IFACEMETHODIMP GlassAccessible::GetVisibleRanges(SAFEARRAY **pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    *pRetVal = callArrayMethod(mid_GetVisibleRanges, VT_UNKNOWN);
-    return S_OK;
+    return callArrayMethod(mid_GetVisibleRanges, VT_UNKNOWN, pRetVal);
 }
 
 IFACEMETHODIMP GlassAccessible::RangeFromChild(IRawElementProviderSimple *childElement,  ITextRangeProvider **pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    jlong ptr = callLongMethod(mid_RangeFromChild, (jlong)childElement);
+    IUnknown* ptr = NULL;
+    HRESULT hr = callLongMethod(mid_RangeFromChild, &ptr, (jlong)childElement);
     *pRetVal = reinterpret_cast<ITextRangeProvider*>(ptr);
-    return S_OK;
+    return hr;
 }
 
 IFACEMETHODIMP GlassAccessible::RangeFromPoint(UiaPoint point, ITextRangeProvider **pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    jlong ptr = callLongMethod(mid_RangeFromPoint, point.x, point.y);
+    IUnknown* ptr = NULL;
+    HRESULT hr = callLongMethod(mid_RangeFromPoint, &ptr, point.x, point.y);
     *pRetVal = reinterpret_cast<ITextRangeProvider*>(ptr);
-    return S_OK;
+    return hr;
 }
 
 IFACEMETHODIMP GlassAccessible::get_DocumentRange(ITextRangeProvider **pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    jlong ptr = callLongMethod(mid_get_DocumentRange);
+    IUnknown* ptr = NULL;
+    HRESULT hr = callLongMethod(mid_get_DocumentRange, &ptr);
     *pRetVal = reinterpret_cast<ITextRangeProvider*>(ptr);
-    return S_OK;
+    return hr;
 }
 
 IFACEMETHODIMP GlassAccessible::get_SupportedTextSelection(SupportedTextSelection *pRetVal)
 {
     JNIEnv* env = GetEnv();
     *pRetVal = (SupportedTextSelection)env->CallIntMethod(m_jAccessible, mid_get_SupportedTextSelection);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -672,22 +671,23 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallIntMethod(m_jAccessible, mid_get_ColumnCount);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
 IFACEMETHODIMP GlassAccessible::get_RowCount(int *pRetVal) {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallIntMethod(m_jAccessible, mid_get_RowCount);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
 IFACEMETHODIMP GlassAccessible::GetItem(int row, int column, IRawElementProviderSimple **pRetVal) {
     if (pRetVal == NULL) return E_INVALIDARG;
-    jlong ptr = callLongMethod(mid_GetItem, row, column);
+    IUnknown* ptr = NULL;
+    HRESULT hr = callLongMethod(mid_GetItem, &ptr, row, column);
     *pRetVal = reinterpret_cast<IRawElementProviderSimple*>(ptr);
-    return S_OK;
+    return hr;
 }
 
 /***********************************************/
@@ -696,7 +696,7 @@
 IFACEMETHODIMP GlassAccessible::get_Column(int *pRetVal) {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallIntMethod(m_jAccessible, mid_get_Column);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -704,29 +704,30 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallIntMethod(m_jAccessible, mid_get_ColumnSpan);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
 IFACEMETHODIMP GlassAccessible::get_ContainingGrid(IRawElementProviderSimple **pRetVal){
     if (pRetVal == NULL) return E_INVALIDARG;
-    jlong ptr = callLongMethod(mid_get_ContainingGrid);
+    IUnknown* ptr = NULL;
+    HRESULT hr = callLongMethod(mid_get_ContainingGrid, &ptr);
     *pRetVal = reinterpret_cast<IRawElementProviderSimple*>(ptr);
-    return S_OK;
+    return hr;
 }
 
 IFACEMETHODIMP GlassAccessible::get_Row(int *pRetVal)
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallIntMethod(m_jAccessible, mid_get_Row);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
 IFACEMETHODIMP GlassAccessible::get_RowSpan(int *pRetVal) {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallIntMethod(m_jAccessible, mid_get_RowSpan);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -736,21 +737,19 @@
 IFACEMETHODIMP GlassAccessible::GetColumnHeaders(SAFEARRAY **pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    *pRetVal = callArrayMethod(mid_GetColumnHeaders, VT_UNKNOWN);
-    return S_OK;
+    return callArrayMethod(mid_GetColumnHeaders, VT_UNKNOWN, pRetVal);
 }
 
 IFACEMETHODIMP GlassAccessible::GetRowHeaders(SAFEARRAY **pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    *pRetVal = callArrayMethod(mid_GetRowHeaders, VT_UNKNOWN);
-    return S_OK;
+    return callArrayMethod(mid_GetRowHeaders, VT_UNKNOWN, pRetVal);
 }
 
 IFACEMETHODIMP GlassAccessible::get_RowOrColumnMajor(RowOrColumnMajor *pRetVal) {
     JNIEnv* env = GetEnv();
     *pRetVal = (RowOrColumnMajor) env->CallIntMethod(m_jAccessible, mid_get_RowOrColumnMajor);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -761,15 +760,13 @@
 IFACEMETHODIMP GlassAccessible::GetColumnHeaderItems(SAFEARRAY **pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    *pRetVal = callArrayMethod(mid_GetColumnHeaderItems, VT_UNKNOWN);
-    return S_OK;
+    return callArrayMethod(mid_GetColumnHeaderItems, VT_UNKNOWN, pRetVal);
 }
 
 IFACEMETHODIMP GlassAccessible::GetRowHeaderItems(SAFEARRAY **pRetVal)
 {
     if (pRetVal == NULL) return E_INVALIDARG;
-    *pRetVal = callArrayMethod(mid_GetRowHeaderItems, VT_UNKNOWN);
-    return S_OK;
+    return callArrayMethod(mid_GetRowHeaderItems, VT_UNKNOWN, pRetVal);
 }
 
 
@@ -780,7 +777,7 @@
 {
     JNIEnv* env = GetEnv();
     env->CallVoidMethod(m_jAccessible, mid_Toggle);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -788,7 +785,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = (ToggleState) env->CallIntMethod(m_jAccessible, mid_get_ToggleState);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -799,7 +796,7 @@
 {
     JNIEnv* env = GetEnv();
     env->CallVoidMethod(m_jAccessible, mid_Collapse);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -807,7 +804,7 @@
 {
     JNIEnv* env = GetEnv();
     env->CallVoidMethod(m_jAccessible, mid_Expand);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -815,7 +812,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = (ExpandCollapseState) env->CallIntMethod(m_jAccessible, mid_get_ExpandCollapseState);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -826,7 +823,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallBooleanMethod(m_jAccessible, mid_get_CanMove);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -834,7 +831,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallBooleanMethod(m_jAccessible, mid_get_CanResize);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -842,7 +839,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallBooleanMethod(m_jAccessible, mid_get_CanRotate);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -850,7 +847,7 @@
 {
     JNIEnv* env = GetEnv();
     env->CallVoidMethod(m_jAccessible, mid_Move, x, y);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -858,7 +855,7 @@
 {
     JNIEnv* env = GetEnv();
     env->CallVoidMethod(m_jAccessible, mid_Resize, width, height);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -866,7 +863,7 @@
 {
     JNIEnv* env = GetEnv();
     env->CallVoidMethod(m_jAccessible, mid_Rotate, degrees);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -877,7 +874,7 @@
 {
     JNIEnv* env = GetEnv();
     env->CallVoidMethod(m_jAccessible, mid_Scroll, horizontalAmount, verticalAmount);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -885,7 +882,7 @@
 {
     JNIEnv* env = GetEnv();
     env->CallVoidMethod(m_jAccessible, mid_SetScrollPercent, horizontalPercent, verticalPercent);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -893,7 +890,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallBooleanMethod(m_jAccessible, mid_get_HorizontallyScrollable);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -901,7 +898,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallDoubleMethod(m_jAccessible, mid_get_HorizontalScrollPercent);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -909,7 +906,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallDoubleMethod(m_jAccessible, mid_get_HorizontalViewSize);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -917,7 +914,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallBooleanMethod(m_jAccessible, mid_get_VerticallyScrollable);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -925,7 +922,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallDoubleMethod(m_jAccessible, mid_get_VerticalScrollPercent);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -933,7 +930,7 @@
 {
     JNIEnv* env = GetEnv();
     *pRetVal = env->CallDoubleMethod(m_jAccessible, mid_get_VerticalViewSize);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
@@ -944,7 +941,7 @@
 {
     JNIEnv* env = GetEnv();
     env->CallVoidMethod(m_jAccessible, mid_ScrollIntoView);
-    CheckAndClearException(env);
+    if (CheckAndClearException(env)) return E_FAIL;
     return S_OK;
 }
 
--- a/modules/graphics/src/main/native-glass/win/GlassAccessible.h	Mon Apr 21 15:30:22 2014 -0700
+++ b/modules/graphics/src/main/native-glass/win/GlassAccessible.h	Mon Apr 21 17:00:35 2014 -0700
@@ -170,10 +170,10 @@
     virtual ~GlassAccessible();
 
     /* Call the method specified by 'mid', AddRef the returning ptr (expects result to be IUnkonwn) */
-    virtual jlong callLongMethod(jmethodID mid, ...);
+    virtual HRESULT callLongMethod(jmethodID mid, IUnknown **pRetVal, ...);
 
     /* Call the method specified by 'mid' and converts the returning jarray to a SAFEARRAY */
-    virtual SAFEARRAY* callArrayMethod(jmethodID mid, VARTYPE vt);
+    virtual HRESULT callArrayMethod(jmethodID mid, VARTYPE vt, SAFEARRAY **pRetVal);
 
     ULONG m_refCount;
     jobject m_jAccessible;  // The GlobalRef Java side object