[concurrency-interest] LinkedBlockingQueue does not throw ClassCastException
dcholmes at optusnet.com.au
Mon Apr 16 18:39:57 EDT 2007
You can't write a test for "optional" behaviour without some way of knowing
whether the implementation you are testing is trying to support that
My only suggestion is skip the test because it isn't testable without
external knowledge of the concrete collection type.
> -----Original Message-----
> From: Szabolcs Ferenczi [mailto:szabolcs.ferenczi at gmail.com]
> Sent: Tuesday, 17 April 2007 8:35 AM
> To: dholmes at ieee.org
> Cc: Concurrency-interest at cs.oswego.edu
> Subject: Re: [concurrency-interest] LinkedBlockingQueue does not throw
> On 17/04/07, David Holmes <dcholmes at optusnet.com.au> wrote:
> > And you'll get the ClassCastException when you attempt to
> extract the String
> > as an Integer.
> > The line in Collection.add that says "... others will impose
> restrictions on
> > the type of elements that may be added." is not referring to
> Generics, but
> > specific concrete implementations that might impose their own direct
> > instanceof checks eg pre-generic ListInteger, SetString etc.
> Thanks a lot. So what is your suggestion for the test exactly?
> Best Regards,
More information about the Concurrency-interest