Does the GWT compiler have problems with Generics?

60 views
Skip to first unread message

marcelstoer

unread,
Feb 8, 2009, 11:29:40 AM2/8/09
to Google Web Toolkit
My *Async interface contains the following method signature:

void reportsAvailableFor(Class<? extends AbstractRow> rowClass,
AsyncCallback<Boolean> callback);

The method signature in the application i.e. Servlet interface
likewise looks like:

Boolean reportsAvailableFor(Class<? extends AbstractRow> rowClass);

The GWT shell complains at startup that:

[ERROR] Type 'java.lang.Class<? extends
ch.netcetera.eveni.client.model.table.AbstractRow>' was not
serializable and has no concrete serializable subtypes

At that point I thought that GWT had an issue with the Generics
parameter. Hence, I removed the restrictive "<? extends AbstractRow>"
suffix from the Class type, but GWT still complains about:

"'java.lang.Class' was not serializable and has no concrete
serializable subtypes"

Now this is definitely bogus IMO as java.lang.Class<T> clearly states
"implements java.io.Serializable" - and yes, I'm using GWT 1.5.3.

Marcel




Damien Picard

unread,
Feb 8, 2009, 11:37:06 AM2/8/09
to Google-We...@googlegroups.com
Hi,

Your class has to implement the interface com.google.gwt.user.client.rpc.IsSerializable and you have to add a free-parameters constructor as is :

public class MyClass implements IsSerializable{

    public MyClass(){
         ...
    }
}

Maybe this default constructor misses ?

Regards
Damien Picard.

2009/2/8 marcelstoer <mar...@frightanic.com>

marcelstoer

unread,
Feb 8, 2009, 11:43:39 AM2/8/09
to Google Web Toolkit
Thanks for your quick reply.

On Feb 8, 5:37 pm, Damien Picard <picard.dam...@gmail.com> wrote:
> Hi,
>
> Your class has to implement the interface
> com.google.gwt.user.client.rpc.IsSerializable and you have to add a

As of GWT 1.5 this is no longer required, implementing
java.io.Serializable is enough.

> free-parameters constructor as is :
>
> public class MyClass implements IsSerializable{
>
>     public MyClass(){
>          ...
>     }
>
> }
>
> Maybe this default constructor misses ?

Yes, indeed. I totally forgot about the default constructor. Thanks
for pointing that out. java.lang.Class does have a no-args
constructor, but it's private.

I just whish the GWT compiler were a little more verbose or precise
about the problem.

Marcel

Damien Picard

unread,
Feb 8, 2009, 11:52:55 AM2/8/09
to Google-We...@googlegroups.com
You're welcome.

I've already been confronted with this problem and the GWT compiler is not verbose with this.
I've find this information in a tutorial where these two conditions was exposed.



2009/2/8 marcelstoer <mar...@frightanic.com>
Reply all
Reply to author
Forward
0 new messages