I have an interface annotated with @JsFunction that I use as a callback for events. As there are different types of events, I have added a type parameter:
@JsFunction
public interface Function<T extends Event>{
public JavaScriptObject call(T event);
}From the entry point I do something like :
//...
map.on("click", new Function<MouseEvent>(){
@Override
public JavaScriptObject call(MouseEvent event) {
});When I run the project, everything compiles and run fine. But when the code above is executed, I get the following exception in the console:
Uncaught java.lang.ClassCastException InternalPreconditions.java:45
This seems like a GWT internal error. Is this a known bug in GWT 2.8 ? Are generics not allowed with JsInterop types?
@JsFunction
public interface Function{
public JavaScriptObject call(JavaScriptObject event);
}@JsType
public class MouseEvent extends JavaScriptObject {
protected MouseEvent(){}
public final native String getType() /*-{
return this.target;
}-*/;
}
map.on("click", new Function(){
@Override
public JavaScriptObject call(JavaScriptObject event) {
MouseEvent msEvent = event.cast();
});Thanks for your suggestion. SNAPHOT did resolve this error, but caused others.
Hoping that the stable release will correct this issue.