Re: Simple question about GWT.create() signature
On 29 nov, 10:55, ep eplisc...@googlemail.com wrote: Thomas, in fact it would be really nice if GWT.create() would not require literals, we wanted to use a template method throughout our framework to allow to declare the classes to instantiate, maybe you can provide the issue number so we can vote for it :-) There are many issues re. changing GWT.create specifics. Here are a few: http://code.google.com/p/google-web-toolkit/issues/list?q=gwt.create+literal (and follow the links within the issues themselves!) See also: http://timepedia.blogspot.com/2009/03/relaxing-constraints-on-gwtcreate.html (Ray Cromwell is now working at Google, on GWT) -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Simple question about GWT.create() signature
Thank you for the reply I did not know much about GWT-RPC, bay be I should study more before making questions... I was aware of the generic call, but looks to me like a cast :) I was NOT aware of the feature called 'type inference'. I used my IDE to complete, and noticed that only Object methods were allowed chained after a GWT.create(), so I thought that I needed a cast to assign to a variable. Now I readed the java tutorial on Generic Methods and everything looks much more consistent... I knew about generic methods, but missing the type inference I always wondered what were they useful to... :) On 28 Nov, 10:56, Thomas Broyer t.bro...@gmail.com wrote: On 26 nov, 21:12, Alessandro Carraro (JUG Padova) carraro.alessan...@gmail.com wrote: A simple qestion, sorry if it is a FAQ: Why public static T T create(Class? classLiteral) and not public static T T create(ClassT classLiteral) With GWT-RPC you pass the synchronous (extends RemoteService) interface as an argument and it returns an implementation of the asynchronous interface. That wouldn't be possible with the ClassT argument. the second one would save me from a lot of unnecessary casts (IMHO). I hardly ever needed a cast: - either the GWT.create() result is assigned to a variable, and javac/ GWT compiler is smart enough to infer the generic type argument - or if it's not possible, you can use a generic call instead of a cast: GWT.MyClasscreate(...) but I admit it adds the same boilerplate as a cast... What's worse, I tried to write the helper function: @SuppressWarnings(unchecked) public static T T create(ClassT classLiteral) { return (T) GWT.create(classLiteral); } But after a month I discovered that the compiler does not like it at all (it complains that GWT.create must be called only using class literals... could be nice if it could find that MY helper is called with only using literals... It's been requested several types in the past (including by people that now work at Google on GWT) but I guess it's either low priority or it would require too much re-work of the compiler's internals. Is it possible to get a hook into the compiler phase to replace all invocations of my helper 'inlining' it? I don't think so; but is it really worth it? risking bugs in your hook just to save you from typing a few characters (that, moreover, any good IDE is capable of generating for you) -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Simple question about GWT.create() signature
Thomas, in fact it would be really nice if GWT.create() would not require literals, we wanted to use a template method throughout our framework to allow to declare the classes to instantiate, maybe you can provide the issue number so we can vote for it :-) But after a month I discovered that the compiler does not like it at all (it complains that GWT.create must be called only using class literals... could be nice if it could find that MY helper is called with only using literals... It's been requested several types in the past (including by people that now work at Google on GWT) but I guess it's either low priority or it would require too much re-work of the compiler's internals. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Simple question about GWT.create() signature
On 26 nov, 21:12, Alessandro Carraro (JUG Padova) carraro.alessan...@gmail.com wrote: A simple qestion, sorry if it is a FAQ: Why public static T T create(Class? classLiteral) and not public static T T create(ClassT classLiteral) With GWT-RPC you pass the synchronous (extends RemoteService) interface as an argument and it returns an implementation of the asynchronous interface. That wouldn't be possible with the ClassT argument. the second one would save me from a lot of unnecessary casts (IMHO). I hardly ever needed a cast: - either the GWT.create() result is assigned to a variable, and javac/ GWT compiler is smart enough to infer the generic type argument - or if it's not possible, you can use a generic call instead of a cast: GWT.MyClasscreate(...) but I admit it adds the same boilerplate as a cast... What's worse, I tried to write the helper function: @SuppressWarnings(unchecked) public static T T create(ClassT classLiteral) { return (T) GWT.create(classLiteral); } But after a month I discovered that the compiler does not like it at all (it complains that GWT.create must be called only using class literals... could be nice if it could find that MY helper is called with only using literals... It's been requested several types in the past (including by people that now work at Google on GWT) but I guess it's either low priority or it would require too much re-work of the compiler's internals. Is it possible to get a hook into the compiler phase to replace all invocations of my helper 'inlining' it? I don't think so; but is it really worth it? risking bugs in your hook just to save you from typing a few characters (that, moreover, any good IDE is capable of generating for you) -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.