[concurrency-interest] LinkedBlockingQueue does not throwClassCastException

Martin Buchholz Martin.Buchholz at Sun.COM
Tue Apr 17 06:05:13 EDT 2007

> From: "David Holmes" <dcholmes at optusnet.com.au>
> Subject: Re: [concurrency-interest] LinkedBlockingQueue does not
> 	throwClassCastException
> To: "Szabolcs Ferenczi" <szabolcs.ferenczi at gmail.com>
> Cc: Concurrency-interest at cs.oswego.edu
> Message-ID: <NFBBKALFDCPFIDBNKAPCIEFBHGAA.dcholmes at optusnet.com.au>
> Content-Type: text/plain;	charset="us-ascii"
> If you check the documentation you will see that LinkedBlockingQueue.add is
> inherited from AbstractQueue.add, and the latter does *not* throw
> ClassCastException.

It's a very interesting point that it is possible to tell from the
javadoc whether a subclass has overridden a method.  But that is
clearly an implementation detail, and its exposure by javadoc
presumably a subtle bug in javadoc.  The spec should not be construed
as guaranteeing that LBQ does not override add().  A compatible
Java implementation could have LBQ override add(), as long as it
had the same spec.


> David Holmes

More information about the Concurrency-interest mailing list