Help with JavaScriptObject casting issue in Prod Mode.

34 views
Skip to first unread message

John Gentilin

unread,
Jun 4, 2012, 10:10:50 PM6/4/12
to google-we...@googlegroups.com
I am working with a wrapper around the FB JS libs, which is actually
running on a iPhone / PhoneGap that is calling the native FB Libs..

I have the following wrapper function that will log me out of FB and
call the success function on return

  public static native void logout (AsyncCallback<JavaScriptObject> callback) /*-{
     $wnd.FB.logout(function(response){
      @com.gwtfb.client.core.FBCore::callbackSuccess(Lcom/google/gwt/user/client/rpc/AsyncCallback;Lcom/google/gwt/core/client/JavaScriptObject;)(callback,response);
   });
    }-*/;

The response method is defined below. During execution, the logout function just returns the
String "OK".  From the diagnostics in the method below, obj is of class java.lang.String and the
callback signature is protected class LoginStatusCallback implements AsyncCallback<JavaScriptObject>

callback.onSuccess (obj); fails with a Class Cast Exception when running in Prod Mode,

The try / catch around callback.onSuccess (obj) does get caught and it successfully calls
the callback with null as a parameter. it just seems off that the obj correctly identifies itself
as an instance of JavaScriptObject but fails on the call.. It works fine hosted mode..


Thank You
John Gentilin

  protected static void callbackSuccess(AsyncCallback<JavaScriptObject> callback, JavaScriptObject obj)
  {
    m_Log.info("FB call response " + obj.toString());
    if (obj instanceof JavaScriptObject )
    {
      m_Log.info(obj.getClass().getName());
      if(callback != null)
      {
        try
        {
          m_Log.info(callback.getClass().getName());
          callback.onSuccess (obj);
        }
        catch(Exception e)
        {
          m_Log.info("Exception in callback, calling success with null");
          callback.onSuccess(null);
        }
      }
    }
    else
    {
      m_Log.info("Other than JavaScript Object returned on callback " +obj.getClass().getName());
    }
  }

Reply all
Reply to author
Forward
0 new messages