On 4 Aug 2011, at 12:01, Sanne Grinovero wrote:

>> This is not as straightforward as it may seem, first there is a
>> question of whether to use template parameters or not:
>> 2.a. Set<Cache> getCaches(String... cacheNames);
>> vs
>> 2.b. Set<Cache<K, V>> getCaches(String... cacheNames);
>> 
>> I don't think having the same K and V for all the caches is going to
>> be very common, so I'd go with 2.a.

Dan and I discussed this on IRC. The JLS says that using the raw type of a 
parameterized type is bad practice

"The use of raw types is allowed only as a concession to compatibility of leg- 
acy code. The use of raw types in code written after the introduction of 
genericity into the Java programming language is strongly discouraged. It is 
possible that future versions of the Java programming language will disallow 
the use of raw types."

The correct signature of 2a. is

Set<? extends Cache<Object, Object>>

which encodes that we never expect K,V to be same for all caches retrieved this 
way.

If we do expect K, V to be the same in any case we should specify it as 
Set<Cache<K, V>> as this allows the compiler to infer the generic type 
arguments, and doesn't prohibit Set<Cache<Object, Object>>, or make any more 
typing for the user.
_______________________________________________
infinispan-dev mailing list
infinispan-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/infinispan-dev

Reply via email to