Re: Java Generics - "super" keyword usage
Avinash Lakshman <[email protected]>
| Newsgroups | gmane.comp.windows.devel.java.advanced |
|---|---|
| Message-ID | <[email protected]> |
Ah never mind. Too early in the morning I guess. Here is what I wanted to ask. Sorry for the confusion:
public <T extends IColumn> ICompactSerializer<T> serializer()
{
// this complains saying cannot convert from MyColumnSerializer to ICompactSerializer<T>
return new MyColumnSerializer();
}
class MyColumnSerializer implements ICompactSerializer<MyColumn>
{
public void serialize(MyColumn column, DataOutputStream dos) throws IOException
{
}
public MyColumn deserialize(DataInputStream dis) throws IOException
{
return null;
}
}
Now this method is defined in an interface
called IColumn. I want any class that implements this serializer()
method to pass its type to the ICompactSerializer template argument. Is
this doable and if so what am I doing wrong?
> Date: Thu, 20 Sep 2007 10:14:45 -0500
> From: [email protected]
> Subject: [ADVANCED-JAVA] Java Generics - "super" keyword usage
> To: [email protected]
>
> Hi All
>
> This has been driving me insane. I am pretty sure it is very simple and hopefully someone can clear this up for me. What is wrong with the following:
>
> public <T super IColumn> ICompactSerializer<T> serializer()
> {
> return new MyColumnSerializer();
> }
>
> class MyColumnSerializer implements ICompactSerializer<MyColumn>
> {
> public void serialize(MyColumn column, DataOutputStream dos) throws IOException
> {
> }
>
> public MyColumn deserialize(DataInputStream dis) throws IOException
> {
> return null;
> }
> }
>
> It complains about the "super" keyword. However the same compiles with the "extends" keyword. Now this method is defined in an interface called IColumn. I want any class that implements this serializer() method to pass its type to the ICompactSerializer template argument. Is this doable and if so what am I doing wrong?
>
> Thanks
> Avinash
>
> _________________________________________________________________
> Can you find the hidden words? Take a break and play Seekadoo!
> http://club.live.com/seekadoo.aspx?icid=seek_wlmailtextlink
> ===================================
> This list is hosted by DevelopMentor® http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
_________________________________________________________________
Kick back and relax with hot games and cool activities at the Messenger Café.
http://www.cafemessenger.com?ocid=TXT_TAGLM_SeptWLtagline
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com