[Fwd: Code review request: 7072353 JNDI libraries do not build with javac -Xlint:all -Werror]

David Holmes David.Holmes at oracle.com
Thu Aug 4 03:42:02 UTC 2011


Joe Darcy said the following on 08/04/11 12:33:
> David Holmes wrote:
>>> Using wildcards makes the subtyping work along the type argument axis.
>>
>> So what is the right fix here? To declare the underlying Vector as a 
>> Vector<?> and cast it to something concrete when needed? It seems very 
>> wrong to me to be inserting raw type casts all through this code.
> 
> It isn't entirely clear to be from a quick inspection of the code what 
> the actual type usage is.  A writable general Vector should be a 
> Vector<Object> and Vector just meant for reading should be a Vector<?> 
> (or the equivalent Vector<? extends Object>).
> 
> If the type usage is "a sequence of X's and Y's" where X and Y don't 
> have some useful supertype, I would recommend using a somewhat different 
> set of data structures, like a list of type-safe heterogeneous 
> containers or a list of a new package-level XorY class.

Buried in one of Sasha's emails it says:

"The current code uses it to store Strings and Vector<String>s."

Hence it is declared Vector<Object>.

This is looking to me like code that should not have been generified.

David

> -Joe



More information about the core-libs-dev mailing list