Re: Java Generics - "super" keyword usage
Avinash Lakshman <[email protected]>
| Newsgroups | gmane.comp.windows.devel.java.advanced |
|---|---|
| Message-ID | <[email protected]> |
I was more impressed with the word "elliptic" - had to look it up but is an awesome word. Yes I have all those definitions. So do you mean something like this:
public <T extends IColumn> ICompactSerializer<T> serializer()
{
return (ICompactSerializer<T>)new MyColumnSerializer();
}
But this causes a compiler warning. So is there no way to represent this?
Thanks
A
> Date: Thu, 20 Sep 2007 09:16:26 -0700
> From: [email protected]
> Subject: Re: [ADVANCED-JAVA] Java Generics - "super" keyword usage
> To: [email protected]
>
> Your snippet was really elliptic. I assumed the following definitions:
>
> interface IColumn { }
> interface ICompactSerializer<T> { }
> class MyColumnSerializer implements ICompactSerializer<MyColumn> { }
> class MyColumn implements IColumn { }
>
> Your problem is that you declare that you are returning a
> ICompactSerializer<T> but are actually returning ICompactSerializer<MyColumn>
> Even if T somehow is a MyColumn the compiler correctly cannot
> figure it out from this context. A cast of MyColumnSerializer
> to ICompactSerializer<T> will succeed but is pretty meaningless
> w/o knowing what is T.
>
> -- O.L.
>
> ===================================
> This list is hosted by DevelopMentor® http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
_________________________________________________________________
Gear up for Halo® 3 with free downloads and an exclusive offer. It’s our way of saying thanks for using Windows Live™.
http://gethalo3gear.com?ocid=SeptemberWLHalo3_WLHMTxt_2
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com