[weld-dev] SQL framework proof of concept

Pete Muir pmuir at redhat.com
Mon Nov 30 07:51:25 EST 2009


On 28 Nov 2009, at 02:44, Arbi Sookazian wrote:

> Following comments apply to seam-sql5 rev...
> 
> 1) In Tuple class:
> 
> public <T> T get(int column, Type<T> type) {
>         return (T) get(column);
>     }
> 
> The type param is not referenced in the body of the method.  Why?

Right, you can rewrite this as

return type.cast(get(column));

which does a runtime cast and doesn't generate compiler warnings.

Really, the reason for passing in the "type" parameter is because type inference in Java isn't that great and the compiler get's it wrong sometimes (interestingly JDT is better at this than javac, so when you recompile on the command line you get additional problems, ouch!). Without that type parameter you will end up having to write

tuple.<Foo>get(1);

occasionally in client code, which is just ugly.

Passing in the type parameter is the best of two bad options IMO.




More information about the weld-dev mailing list