hg: jdk7/tl/jdk: 6921740: Eliminate warnings from sun.io converters and allow compiling with JAVAC_MAX_WARNINGS=true

Rémi Forax forax at univ-mlv.fr
Fri Feb 5 10:20:47 UTC 2010


Le 05/02/2010 01:15, Ulf Zibis a écrit :
> Am 02.02.2010 18:47, schrieb Rémi Forax:
>> Le 02/02/2010 17:26, Ulf Zibis a écrit :
>>> Am 02.02.2010 14:30, schrieb Rémi Forax:
>>>> Le 02/02/2010 14:09, Ulf Zibis a écrit :
>>>>> Hi,
>>>>>
>>>>> in most cases you use the empty diamond operator '<>' on 
>>>>> instantiation, but not for SoftReference: "new 
>>>>> SoftReference<Charset>(cs)" in AbstractCharsetProvider.java
>>>>> Why?
>>>>
>>>> SoftReference constructor is SoftReference(T), so there is two ways 
>>>> to infer the type argument.
>>>>
>>>> With this code:
>>>> SoftReference<Charset> ref = new SoftReference<>(cs);
>>>> the type argument can be infered from the lhs of the assignation or
>>>> by the declared type of the parameter (here cs).
>>>>
>>>
>>> So you agree with me, that new SoftReference<>(cs) would suffice ???
>>
>> No.
>> The code is:
>>
>> cache.put(csn, new SoftReference<Charset>(cs));
>>
>>
>> It will not compile, because Object will be infered.
>> Diamond doesn't take care about method's parameter types
>
> Hm?
> 1. Why ? (IMO would be resonable)
> 2. Didn't you say, type argument can be infered by the declared type 
> of the parameter (here cs) ?
>
> -Ulf
>

For the whole story see:
http://mail.openjdk.java.net/pipermail/coin-dev/2009-November/002393.html

Rémi






More information about the core-libs-dev mailing list