Thanks for your suggestion. SNAPHOT did resolve this error, but caused 
others. I ended up using JSNI and the cast() method of the 
JavaScriptObject. 

@JsFunctionpublic interface Function{

  public JavaScriptObject call(JavaScriptObject event);
}



@JsType
public class MouseEvent extends JavaScriptObject {
        
    protected MouseEvent(){}


   public final native  String getType() /*-{
        return this.target;
    }-*/;


}


and then: 

map.on("click", new Function(){
        @Override
        public JavaScriptObject call(JavaScriptObject event) {


          MouseEvent msEvent = event.cast();

    });



This is the only workaround I found for now, although I would have prefered 
to use JsInterop only. Hoping that the stable release will correct this 
issue. 



Le mardi 26 juillet 2016 17:07:00 UTC+2, Thomas Broyer a écrit :
>
>
>
> On Tuesday, July 26, 2016 at 4:45:03 PM UTC+2, zakaria amine wrote:
>>
>> 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:
>>
>>
>> @JsFunctionpublic 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?
>>
>
> Many things have changed since 2.8.0-beta1, have you tried with 
> 2.8.0-SNAPSHOT? (I'm not saying it *will* work, I'm saying one shouldn't 
> draw conclusions based on beta1)
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to