commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Benson (JIRA)" <>
Subject [jira] [Commented] (LANG-819) EnumUtils.generateBitVector needs a "? extends"
Date Mon, 06 Jan 2014 05:26:51 GMT


Matt Benson commented on LANG-819:

What have I said to lead you to conclude that I misunderstand type bounds?  It almost seems
(and I hope I'm wrong) that I understand them in such a fundamental way that I cannot be easily
talked into doing something that makes _perfect_ sense in the general case, but feels totally
useless in this specific one.

Your example is all well and good _for non-{{final}} types_, but {{Set<? extends Foo>}}
is IMHO a red herring.  {{EnumSet.allOf(Foo.class)}} returns {{EnumSet<Foo>}}, _not_
{{EnumSet<? extends Foo>}}; therefore the entire example is contrived.  If for some
reason you were using a {{Set}} of whatever element type that you didn't already _know_ was
{{enum}} you'd never _pass_ that {{Set}} to {{EnumUtils#generateBitVector()}} without first
somehow checking that, at which point you'd have to cast the {{Set}} anyway to call the bit
vector method.

I comprehend that you are saying the {{? extends E}} idiom makes the compiler disallow the
modification of a {{Collection}} (an {{Iterable}} can't be modified without casting to {{Collection}}
anyway) and I can make the logical leap that _because of this_ it may be a visual shorthand
for "read-only," yet I _still_ stubbornly refuse to be bullied by this fact when you have

* explained your (lacking clarification, striking me as rude and condescending) assertion
that I "misunderstand type bounds"
* provided a realistic example of code that suffers because of the current parameter specification
* explained how [this comment|]
is germane to the discussion


> 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