我有以下GWT
代码:
package my.package.name;
public class MyImpl {
public void scan(AsyncCallback<String> callBack) {
this.callBack = callBack;
scanJNSI();
}
private native void scanJNSI()/*-{
var instance = this;
instance.@my.package.name.MyImpl::onError(Ljava/lang/String;)("BROWSER");
}-*/;
private void onError(String obj) {
callBack.onFailure(new Exception(obj));
}
}
当我打电话时:
instance.scan(new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {
Window.alert(result);
}
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
}
});
我得到一个Caused by: java.lang.ClassCastException: null
:
Caused by: java.lang.ClassCastException: null
at java.lang.Class.cast(Class.java:2990)
at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:163)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:57)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
at my.package.name.MyImpl.scanJNSI(MyImpl.java)
at my.package.name.MyImpl.scan(MyImpl.java:12)
什么可能是它无法投射的类?