Reputation: 9649
Sometimes my GWT app reports an "Uncaught IllegalArgumentException" below. The error log effectively masks any possible cause from the app. How would you pin down the source of the problem pragmatically in this case?
[ERROR] [mygwtapp] Uncaught exception escaped
java.lang.IllegalArgumentException: Something other than a Java object was returned from JSNI method '@com.google.gwt.core.client.impl.Impl::apply(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)': JS value of type boolean, expected java.lang.Object
at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:178)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:271)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:662)
Upvotes: 0
Views: 2836
Reputation: 19975
With JSNI, you must return only:
So you can return boolean or make your own overlay type if primitives don't meet your needs. But otherwise stick with the primitive boolean.
Upvotes: 2
Reputation: 14877
This error occurs when you have type mismatch from return value of called JSNI function.
For example:
public class GWTTest implements EntryPoint
{
public void onModuleLoad() {
if(get()==false){
System.out.println(get());
}
}
private native Boolean get()/*-{
return false;
}-*/;
}
Here you will get error "java.lang.IllegalArgumentException: Something other than a Java object was returned from JSNI method"
Remember: There is no autoboxing in javascript.
You should return boolean, not Boolean.
Upvotes: 2
Reputation: 64541
In case you're not using Chrome, in which case it's a known bug and the only solution is to switch to Firefox or IE for DevMode or wait for SuperDevMode (expected for GWT 2.5, to be released in a month or so), then your best bet is to try to reproduce it in prod mode.
You could also check your JSNI methods (because it would likely come from your own code), for one that could possibly return a boolean instead of an object (tin this specific case).
Upvotes: 3