Poor feedback for type JSNI return type mismatch

39 views
Skip to first unread message

Mat Gessel

unread,
Aug 14, 2006, 4:30:49 PM8/14/06
to GWT Group
If you try to return a JavaScriptObject from a method that declares a
return type of int you will get the following stack trace.

org.eclipse.swt.SWTException: Failed to change Variant type result = -2147352571
at org.eclipse.swt.ole.win32.OLE.error(OLE.java:332)
at org.eclipse.swt.ole.win32.Variant.getInt(Variant.java:524)
at com.google.gwt.dev.shell.ie.ModuleSpaceIE6.invokeNativeInt(ModuleSpaceIE6.java:208)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeInt(JavaScriptHost.java:87)
at asquare.gwt.tk.client.UtilTC.arrayGetInt(JsUtil.java:187)
at asquare.gwt.tk.test.UtilTC.testArraySetGet(UtilTC.java:216)

My question is could GWT throw a more useful error? Or could the
SWTException be wrapped in a JavaScriptException?


Below is the code I used to generate the exception:

public static native JavaScriptObject arrayNewArray(int length) /*-{
if (length < 0)
throw new Error();
return new Array(length);
}-*/;

public static native void arraySet(JavaScriptObject array, int index,
Object value) /*-{
array[index] = value;
}-*/;

public static native int arrayGetInt(JavaScriptObject array, int index) /*-{
return array[index];
}-*/;

public void testArraySet()
{
JavaScriptObject array = arrayNewArray(0);
Object o = new Object();
arraySet(array, 0, o);
arrayGetInt(array, 0);
}

--
Mat Gessel
http://www.asquare.net

Reply all
Reply to author
Forward
0 new messages