RFR 7118066: Warnings in java.util.concurrent package (original) (raw)

David Holmes david.holmes at oracle.com
Tue Dec 6 01:12:23 UTC 2011


Chris, Doug,

A few nits see below.

Cheers, David

As a matter of style can we ensure annotations are on separate lines. I find this:

@SuppressWarnings("unchecked") E x = (E) items[takeIndex];

hard to read. (I hate seeing local variable annotations in the first place - way too much clutter in my opinion.)

Is the reason for constructs like this:

HashEntry<K,V>[] tab = (HashEntry<K,V>[])new HashEntry<?,?>[cap];

that we can't utilize diamond? Otherwise it would nicely reduce to:

HashEntry<K,V>[] tab = new HashEntry<>[cap];

In ConcurrentSkipListMap:

In Exchanger why suppress the serial warning rather than add the serialVersionId? Elsewhere the id was added. (I prefer to suppress but am querying consistency here)

In LinkedTransferQueue we changed:

this.cast(item);

to

LinkedTransferQueue.cast(item);

but in ArrayBlockingQueue we simply changed to: (E) item. Were these cast methods introduced simply to localize the unchecked suppression?

Also in LinkedTransferQueue we went from:

   E e;
   while ( (e = poll()) != null) {

to

   for (E e; (e = poll()) != null;) {

the side-effect on the loop condition is ugly in a for-loop. Why change from the while? Why not change to a proper for-loop:

for (E e = poll(); e != null; e = poll()) {

In SynchronousQueue:

On 6/12/2011 1:36 AM, Chris Hegarty wrote:

Cleanup warnings in the j.u.c. package. This is a sync up with the warning fixes in Doug's CVS. There are also a few style cleanups, import fixes, trivial local variable renaming, typos, etc. But nothing too surprising! 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.



More information about the core-libs-dev mailing list