commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörg Schaible <joerg.schai...@gmx.de>
Subject Re: [POOL] can the CheckedObjectPool be removed when introducing Java5 generics?
Date Tue, 12 Oct 2010 10:19:15 GMT
sebb wrote:

> On 12 October 2010 10:06, Jörg Schaible <joerg.schaible@gmx.de> wrote:
>> Hi Simone,
>>
>> Simone Tripodi wrote:
>>
>>> Hi all mates,
>>> please help me, even if I temporary fixed the compiler issue, I didn't
>>> understand why
>>>
>>> <K,V> void prefill(final KeyedObjectPool<K,V> keyedPool, final K
>>> key, final int count) throws Exception, IllegalArgumentException
>>> <K,V> void prefill(final KeyedObjectPool<K,V> keyedPool, final
>>> Collection<K> keys, final int count) throws Exception,
>>> IllegalArgumentException
>>>
>>> when using Object as K so problem is represented. Please help me
>>> understand because it's driving me crazy.
>>> I noticed Eclipse ignores it, javac from command line not...
>>>
>>> Many thanks in advance for saving my mental health :)
>>> Simo
>>
>> You cannot trust the Eclipse compiler when using generics. It is a lot
>> smarter then Sun's javac. Collection is an Object and therefore Sun's
>> compiler does not know for if it should use the method with K or
>> Collection<K> if that parameter is an collection of objects :-/
> 
> Is there a solution to this ambiguity, apart from renaming one of the
> methods?

Sometimes it is possible to resolve the ambiguity by calling the method with 
explicit generic parameter:

foo.<X>method();

Depends on the case though.

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message