Hi,

you have to use non-generic definition for GWT:; i.e. Class<?> and
then probably implement a DTO (Data Transfer Object) if you want to
keep the Class<T extends...> on server-side and have just Class<?> on
client side. That's how I do it personnally.

regards

didier

On Dec 14, 1:57 pm, Paul Robinson <[email protected]> wrote:
> The hashCode() contract does not specify that the value should be the
> same on all JVMs. In fact, the javadoc for hashCode() specifically
> states that the value may be different for different invocations of an
> application. It's only guaranteed not to change during a JVM (and only
> when the content of the object doesn't change)
>
> That means you shouldn't rely on the value of hashCode() being the same
> between real JVMs, let alone between the gwt client and a java server.
>
> On 14/12/10 11:20, yves wrote:
>
> > @Didier
> > Of course MyType implements Serializable . It is just a typo in the
> > example. Sorry.
>
> > @Paul
> > I didn't realized that Class is not GWT-serializable. Thanks for your
> > remark. I lost pretty much time to find out why I get an exception
> > during an RPC call
>
> > It would have been nice if Class<T>  was serializable. I would have
> > used it to select an appropriate handler at server-side. Anyway I use
> > instead the canonical class name to map the handler, but the code is
> > little bit more uggly :-)
>
> > I noticed also the a call to class.hashCode() does not give the same
> > value in the (gwt-compiled)-client and in the (JVM running)-server.
> > In my attempts to workaround the "unserializability" of Class, I tried
> > to use the hashCode() value, unsuccessfully...
>
> > Regards
> > Yves
>
> > On 14 d�c, 10:42, Paul Robinson<[email protected]>  wrote:
>
> >> Class is not gwt-serializable.
>
> >> MyType has a non-final, non-transient field of type Class
>
> >> Therefore MyType is not serializable
>
> >> On 14/12/10 09:33, Didier Durand wrote:
>
> >>> Hi,
>
> >>> Serializable is an interface not a class. That's why it's not the list
> >>> you mention. An interface has nothing to be serialized per se.
>
> >>> You should let us know about your class MyType in order to better
> >>> help.
>
> >>> regards
>
> >>> didier
>
> >>> On Dec 14, 9:21 am, Paul Robinson<[email protected]>    wrote:
>
> >>>> If you look at the Class.java that GWT uses to emulate the JVM's Class,
> >>>> you'll see that it does not implement Serializable.
>
> >>>> On 13/12/10 22:19, yves wrote:
>
> >>>>> Hi,
>
> >>>>> I have a class defined in a way similar to this:
>
> >>>>> class MyType<T extends MyGen>      extends Serializable {
>
> >>>>>       private Class<T>      aClass;
>
> >>>>>       public MyType() {}
>
> >>>>>       public void setClass(Class<T>      aClass) {
> >>>>>          this.aClass = aClass;
> >>>>>       }
> >>>>> }
>
> >>>>> where MyGen is also Serializable
>
> >>>>> When I compile de project (I'am currently still using GWT 2.1.0 RC1),
> >>>>> then I find the following :
>
> >>>>> 1) the compiler (using the compiler options -extra, -work and -gen)
> >>>>> does not generate the code MyType_FieldSerializer.java as it does for
> >>>>> all other serializable classes.
>
> >>>>> 2) In the "extra" / rpclog dir, the class MyType is flagged like this:
> >>>>>       Serialization status
> >>>>>          Not serializable
>
> >>>>> 3) And when I run my app, I get an "InvocationException" : the client
> >>>>> is unable to make an RPC call with a parameter of type MyType.
>
> >>>>> Is it a bug in the compiler, or did I missed something about Class<T>
> >>>>> "serializability" ?
>
> >>>>> Thanks for your help
> >>>>> Yves

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to