RFR 7118066: Warnings in java.util.concurrent package

Doug Lea dl at cs.oswego.edu
Mon Dec 5 18:32:14 UTC 2011


On 12/05/11 12:54, Maurizio Cimadamore wrote:
>> http://cr.openjdk.java.net/~chegar/7118066/webrev.00/webrev/
>>
>> -Chris.
>>
>> P.S. I have already reviewed this, and the contribution is of course from Doug.
> Nice work! Some comments below:

Thanks for looking at this!
In both cases, reducing warnings would clash with other conventions
we use in j.u.c:

>
> *) ArrayBlockingQueue: would it make sense to change the declared type of
> 'items' to be E[] instead of Object[] ? This will create one unchecked warnings
> for sure (when the variable is initialized) - but all remaining unchecked cast
> can go away.

After some vacillation, we now always use "Object[]" for holding
generics. It can produce more warnings, but all in all seems to
leave the least room for other kinds of errors to slip in.
Plus it keeps me from remembering so often about how
generics don't work with arrays :-)

>
> *) SynchronousQueue: it seems that if the class SNode was generified, it would
> be possible to get rid of the warnings in the 'transfer' method without adding a
> global @SuppressWarnings.

Yes, possible but it would preclude (or force lying to the type system about)
using sentinels that we often need to use for the sake of GC/cleanup.
So again, by convention, we always use plain Object in these non-blocking
data structures.

-Doug




More information about the core-libs-dev mailing list