commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <>
Subject [jira] [Commented] (LANG-819) EnumUtils.generateBitVector needs a "? extends"
Date Fri, 10 Jan 2014 13:38:08 GMT


Thomas Neidhart commented on LANG-819:

The idea of using <? extends X> collections to prevent modification by compile-time
checks is new to me I have to admit. Although the add-type methods may not work, the resulting
collections are still modifiable, e.g. calling clear() or remove() will still work, thus I
am unsure if this is really sufficient and the right tool for this purpose. Afaik a better
way is to pass unmodifiable collections in such cases.

Anyway, your rant is a bit unfair, as we normally also allow this idiom as input argument
where possible, see for example the latest collections release.

btw. the guys at google do great stuff, so there surely must be a good reason why they do
not use the idiom all the time:,%20java.lang.Class%29

Feel free to rant also on their mailinglist ...

> EnumUtils.generateBitVector needs a "? extends"
> -----------------------------------------------
>                 Key: LANG-819
>                 URL:
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 3.0.1
>            Reporter: Shevek
>            Priority: Minor
>     public static <E extends Enum<E>> long generateBitVector(Class<E>
enumClass, Iterable<E> values) {
> Should be Iterable<? extends E>.
> This is because although no subclasses of E can exist, the "? extends" is a common idiom
for marking the collection as readonly, or not "owned" by the current object.

This message was sent by Atlassian JIRA

View raw message