RFR 7118066: Warnings in java.util.concurrent package
Rémi Forax
forax at univ-mlv.fr
Tue Dec 6 01:45:47 UTC 2011
On 12/06/2011 02:12 AM, David Holmes wrote:
> 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];
This should not compile because otherwise you can write
HashEntry<String,String>[] tab = new HashEntry<>[12];
Object[] o = tab;
o[1] = new HashEntry<Integer, Integer>();
The VM should reject the line above by throwing an ArrayStoreException
but because of the erasure, it will not. So creating an array of
parameterized type
is only possible if you create a reifed type that inherits from an array
of parameterized type.
By example, this code is valid:
enum Foo { foo }
Enum<Foo>[] enums = Foo.values();
Rémi
>
>
>
> 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