You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Steve Ulrich (JIRA)" <ji...@apache.org> on 2009/02/13 17:21:02 UTC

[jira] Created: (FTPSERVER-274) Use Wildcard-Generics in API where possible and plausible

Use Wildcard-Generics in API where possible and plausible
---------------------------------------------------------

                 Key: FTPSERVER-274
                 URL: https://issues.apache.org/jira/browse/FTPSERVER-274
             Project: FtpServer
          Issue Type: Improvement
    Affects Versions: 1.0.0-RC2
            Reporter: Steve Ulrich
             Fix For: 1.0.0


Currently the API doesn't make use of wildcard generic types.
Example FtpFile:

public abstract List<FtpFile> listFiles();
The used generic for the return type prevents users from returning lists with their own type (ie: List<MyFtpFile>).
A change to:

public abstract List<? extends FtpFile> listFiles();

Would allow this without any costs (or I just can't see them *g*)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FTPSERVER-274) Use Wildcard-Generics in API where possible and plausible

Posted by "Steve Ulrich (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FTPSERVER-274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12673824#action_12673824 ] 

Steve Ulrich commented on FTPSERVER-274:
----------------------------------------

Unlike arrays, a generic definition doesn't allow subclasses.
My problem is a good example, I think:
For convenience reasons I had a method named "internalListFiles" which returned an array of type MyFtpFile and the listFiles method just called internalListFiles and returned the resulting array:

public FtpFile[] listFiles(){
  return internalListFiles();
}

private MyFtpFile[] internalListFiles(){
....
}

Here, Java realises that MyFtpFile is a subclass of FtpFile and the arrays are compatible. The new definition doesn't allow this:

public List<FtpFile> listFiles(){
  return internalListFiles(); //Compiler Error: Incompatible types
}

private List<MyFtpFile> internalListFiles(){
....
}

There are two options I see: First would be to copy the List which is a performance drawback, or implement the internalListFiles again, which could lead to "copy and waste".

There's just one drawback of "? extends": You can't add any objects to that list (because you actually don't know the exact type of this list anymore). Which shouldn't be a problem here, since implementations could work with covariant return type. (in my case: List<MyFtpFile> listFiles() )
See http://java.sun.com/docs/books/tutorial/java/generics/subtyping.html for a more detailed explanation.

> Use Wildcard-Generics in API where possible and plausible
> ---------------------------------------------------------
>
>                 Key: FTPSERVER-274
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-274
>             Project: FtpServer
>          Issue Type: Improvement
>    Affects Versions: 1.0.0-RC2
>            Reporter: Steve Ulrich
>             Fix For: 1.1
>
>
> Currently the API doesn't make use of wildcard generic types.
> Example FtpFile:
> public abstract List<FtpFile> listFiles();
> The used generic for the return type prevents users from returning lists with their own type (ie: List<MyFtpFile>).
> A change to:
> public abstract List<? extends FtpFile> listFiles();
> Would allow this without any costs (or I just can't see them *g*)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FTPSERVER-274) Use Wildcard-Generics in API where possible and plausible

Posted by "Niklas Gustavsson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FTPSERVER-274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12673550#action_12673550 ] 

Niklas Gustavsson commented on FTPSERVER-274:
---------------------------------------------

Could you please further explain when this would be useful? I could understand that it would be useful for method the take generic lists as a parameter, but I do not understand where it would be useful for us to return a wildard list? Probably my bad understanding of generics :-)

> Use Wildcard-Generics in API where possible and plausible
> ---------------------------------------------------------
>
>                 Key: FTPSERVER-274
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-274
>             Project: FtpServer
>          Issue Type: Improvement
>    Affects Versions: 1.0.0-RC2
>            Reporter: Steve Ulrich
>             Fix For: 1.1
>
>
> Currently the API doesn't make use of wildcard generic types.
> Example FtpFile:
> public abstract List<FtpFile> listFiles();
> The used generic for the return type prevents users from returning lists with their own type (ie: List<MyFtpFile>).
> A change to:
> public abstract List<? extends FtpFile> listFiles();
> Would allow this without any costs (or I just can't see them *g*)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FTPSERVER-274) Use Wildcard-Generics in API where possible and plausible

Posted by "Niklas Gustavsson (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FTPSERVER-274?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Niklas Gustavsson updated FTPSERVER-274:
----------------------------------------

    Fix Version/s:     (was: 1.0.0)
                   1.1

Rescheduling to 1.1, I don't think this has priority for 1.0.0. Please complain if you think it does.

> Use Wildcard-Generics in API where possible and plausible
> ---------------------------------------------------------
>
>                 Key: FTPSERVER-274
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-274
>             Project: FtpServer
>          Issue Type: Improvement
>    Affects Versions: 1.0.0-RC2
>            Reporter: Steve Ulrich
>             Fix For: 1.1
>
>
> Currently the API doesn't make use of wildcard generic types.
> Example FtpFile:
> public abstract List<FtpFile> listFiles();
> The used generic for the return type prevents users from returning lists with their own type (ie: List<MyFtpFile>).
> A change to:
> public abstract List<? extends FtpFile> listFiles();
> Would allow this without any costs (or I just can't see them *g*)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FTPSERVER-274) Use Wildcard-Generics in API where possible and plausible

Posted by "Steve Ulrich (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FTPSERVER-274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680152#action_12680152 ] 

Steve Ulrich commented on FTPSERVER-274:
----------------------------------------

Yes, the patch looks good. Thank you.
I didn't had the time, since my HDD crashed. It takes some time until everything is up an running again.

> Use Wildcard-Generics in API where possible and plausible
> ---------------------------------------------------------
>
>                 Key: FTPSERVER-274
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-274
>             Project: FtpServer
>          Issue Type: Improvement
>    Affects Versions: 1.0.0-RC2
>            Reporter: Steve Ulrich
>            Assignee: David Latorre
>             Fix For: 1.1
>
>         Attachments: ftpserver.patch
>
>
> Currently the API doesn't make use of wildcard generic types.
> Example FtpFile:
> public abstract List<FtpFile> listFiles();
> The used generic for the return type prevents users from returning lists with their own type (ie: List<MyFtpFile>).
> A change to:
> public abstract List<? extends FtpFile> listFiles();
> Would allow this without any costs (or I just can't see them *g*)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FTPSERVER-274) Use Wildcard-Generics in API where possible and plausible

Posted by "Steve Ulrich (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FTPSERVER-274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680536#action_12680536 ] 

Steve Ulrich commented on FTPSERVER-274:
----------------------------------------

I updated my app, removed the copy stuff and it works like a charm.
Thank you.

> Use Wildcard-Generics in API where possible and plausible
> ---------------------------------------------------------
>
>                 Key: FTPSERVER-274
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-274
>             Project: FtpServer
>          Issue Type: Improvement
>    Affects Versions: 1.0.0-RC2
>            Reporter: Steve Ulrich
>            Assignee: David Latorre
>             Fix For: 1.1
>
>         Attachments: ftpserver.patch
>
>
> Currently the API doesn't make use of wildcard generic types.
> Example FtpFile:
> public abstract List<FtpFile> listFiles();
> The used generic for the return type prevents users from returning lists with their own type (ie: List<MyFtpFile>).
> A change to:
> public abstract List<? extends FtpFile> listFiles();
> Would allow this without any costs (or I just can't see them *g*)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FTPSERVER-274) Use Wildcard-Generics in API where possible and plausible

Posted by "Niklas Gustavsson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FTPSERVER-274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12674142#action_12674142 ] 

Niklas Gustavsson commented on FTPSERVER-274:
---------------------------------------------

That's just fine. With my current work load, me doing this would take even longer :-) And, 1.1 won't be release that soon anyways.

> Use Wildcard-Generics in API where possible and plausible
> ---------------------------------------------------------
>
>                 Key: FTPSERVER-274
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-274
>             Project: FtpServer
>          Issue Type: Improvement
>    Affects Versions: 1.0.0-RC2
>            Reporter: Steve Ulrich
>             Fix For: 1.1
>
>
> Currently the API doesn't make use of wildcard generic types.
> Example FtpFile:
> public abstract List<FtpFile> listFiles();
> The used generic for the return type prevents users from returning lists with their own type (ie: List<MyFtpFile>).
> A change to:
> public abstract List<? extends FtpFile> listFiles();
> Would allow this without any costs (or I just can't see them *g*)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (FTPSERVER-274) Use Wildcard-Generics in API where possible and plausible

Posted by "David Latorre (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FTPSERVER-274?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Latorre closed FTPSERVER-274.
-----------------------------------

    Resolution: Fixed

Thanks for your report and reviews, Steve!




> Use Wildcard-Generics in API where possible and plausible
> ---------------------------------------------------------
>
>                 Key: FTPSERVER-274
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-274
>             Project: FtpServer
>          Issue Type: Improvement
>    Affects Versions: 1.0.0-RC2
>            Reporter: Steve Ulrich
>            Assignee: David Latorre
>             Fix For: 1.1
>
>         Attachments: ftpserver.patch
>
>
> Currently the API doesn't make use of wildcard generic types.
> Example FtpFile:
> public abstract List<FtpFile> listFiles();
> The used generic for the return type prevents users from returning lists with their own type (ie: List<MyFtpFile>).
> A change to:
> public abstract List<? extends FtpFile> listFiles();
> Would allow this without any costs (or I just can't see them *g*)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FTPSERVER-274) Use Wildcard-Generics in API where possible and plausible

Posted by "David Latorre (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FTPSERVER-274?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Latorre updated FTPSERVER-274:
------------------------------------

    Attachment: ftpserver.patch

I hadn't noticed I'm such an ignorant when it comes to java Generics. 

Is this patch a step towards the correct solution?





> Use Wildcard-Generics in API where possible and plausible
> ---------------------------------------------------------
>
>                 Key: FTPSERVER-274
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-274
>             Project: FtpServer
>          Issue Type: Improvement
>    Affects Versions: 1.0.0-RC2
>            Reporter: Steve Ulrich
>            Assignee: David Latorre
>             Fix For: 1.1
>
>         Attachments: ftpserver.patch
>
>
> Currently the API doesn't make use of wildcard generic types.
> Example FtpFile:
> public abstract List<FtpFile> listFiles();
> The used generic for the return type prevents users from returning lists with their own type (ie: List<MyFtpFile>).
> A change to:
> public abstract List<? extends FtpFile> listFiles();
> Would allow this without any costs (or I just can't see them *g*)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (FTPSERVER-274) Use Wildcard-Generics in API where possible and plausible

Posted by "David Latorre (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FTPSERVER-274?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Latorre reassigned FTPSERVER-274:
---------------------------------------

    Assignee: David Latorre

> Use Wildcard-Generics in API where possible and plausible
> ---------------------------------------------------------
>
>                 Key: FTPSERVER-274
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-274
>             Project: FtpServer
>          Issue Type: Improvement
>    Affects Versions: 1.0.0-RC2
>            Reporter: Steve Ulrich
>            Assignee: David Latorre
>             Fix For: 1.1
>
>
> Currently the API doesn't make use of wildcard generic types.
> Example FtpFile:
> public abstract List<FtpFile> listFiles();
> The used generic for the return type prevents users from returning lists with their own type (ie: List<MyFtpFile>).
> A change to:
> public abstract List<? extends FtpFile> listFiles();
> Would allow this without any costs (or I just can't see them *g*)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FTPSERVER-274) Use Wildcard-Generics in API where possible and plausible

Posted by "David Latorre (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FTPSERVER-274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680271#action_12680271 ] 

David Latorre commented on FTPSERVER-274:
-----------------------------------------

Fixed in rev. #751827  - Can you test it, Steve?


> Use Wildcard-Generics in API where possible and plausible
> ---------------------------------------------------------
>
>                 Key: FTPSERVER-274
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-274
>             Project: FtpServer
>          Issue Type: Improvement
>    Affects Versions: 1.0.0-RC2
>            Reporter: Steve Ulrich
>            Assignee: David Latorre
>             Fix For: 1.1
>
>         Attachments: ftpserver.patch
>
>
> Currently the API doesn't make use of wildcard generic types.
> Example FtpFile:
> public abstract List<FtpFile> listFiles();
> The used generic for the return type prevents users from returning lists with their own type (ie: List<MyFtpFile>).
> A change to:
> public abstract List<? extends FtpFile> listFiles();
> Would allow this without any costs (or I just can't see them *g*)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FTPSERVER-274) Use Wildcard-Generics in API where possible and plausible

Posted by "Niklas Gustavsson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FTPSERVER-274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12674042#action_12674042 ] 

Niklas Gustavsson commented on FTPSERVER-274:
---------------------------------------------

Fair enough. Could you provide a patch for this and we'll have a look at it for 1.1?

> Use Wildcard-Generics in API where possible and plausible
> ---------------------------------------------------------
>
>                 Key: FTPSERVER-274
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-274
>             Project: FtpServer
>          Issue Type: Improvement
>    Affects Versions: 1.0.0-RC2
>            Reporter: Steve Ulrich
>             Fix For: 1.1
>
>
> Currently the API doesn't make use of wildcard generic types.
> Example FtpFile:
> public abstract List<FtpFile> listFiles();
> The used generic for the return type prevents users from returning lists with their own type (ie: List<MyFtpFile>).
> A change to:
> public abstract List<? extends FtpFile> listFiles();
> Would allow this without any costs (or I just can't see them *g*)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FTPSERVER-274) Use Wildcard-Generics in API where possible and plausible

Posted by "Steve Ulrich (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FTPSERVER-274?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12674133#action_12674133 ] 

Steve Ulrich commented on FTPSERVER-274:
----------------------------------------

Ok, I will check the API and provide a patch, but this could take a while, as I'll have to do this at home.

> Use Wildcard-Generics in API where possible and plausible
> ---------------------------------------------------------
>
>                 Key: FTPSERVER-274
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-274
>             Project: FtpServer
>          Issue Type: Improvement
>    Affects Versions: 1.0.0-RC2
>            Reporter: Steve Ulrich
>             Fix For: 1.1
>
>
> Currently the API doesn't make use of wildcard generic types.
> Example FtpFile:
> public abstract List<FtpFile> listFiles();
> The used generic for the return type prevents users from returning lists with their own type (ie: List<MyFtpFile>).
> A change to:
> public abstract List<? extends FtpFile> listFiles();
> Would allow this without any costs (or I just can't see them *g*)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.