GWT.create - why the ? wildcard?

49 views
Skip to first unread message

Chris Price

unread,
Feb 20, 2012, 10:41:47 AM2/20/12
to Google Web Toolkit
I've just been caught out by a ClassCastException from GWT.create, it
turned out to be a simple copy/paste fail when writing unit tests but
it got me thinking.

How come GWT.create is defined like so -

public static <T> T create(Class<?> classLiteral) {

instead of like so -

public static <TArg, TRet extends TArg> TRet create(Class<TArg>
classLiteral) {

?

Chris

Thomas Broyer

unread,
Feb 20, 2012, 11:09:08 AM2/20/12
to google-we...@googlegroups.com
Because of GWT-RPC: MyServiceAsync service = GWT.create(MyService.class); MyServiceAsync doesn't extend MyService, they technically have no relationship at all, they're only tied together by a naming rule.

Chris Price

unread,
Feb 20, 2012, 11:20:32 AM2/20/12
to google-we...@googlegroups.com
Thanks, I haven't looked into GWT-RPC since I did the tutorial so I'd
forgotten about that use case.

> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-web-toolkit/-/_IRRvy9La8kJ.
>
> To post to this group, send email to google-we...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-tool...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.

Reply all
Reply to author
Forward
0 new messages