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
Tue Feb 2 09:47:56 PST 2010


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
(Maurizio correct me if I'm wrong)


>
> -Ulf
>

Rémi




More information about the compiler-dev mailing list