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

Ulf Zibis Ulf.Zibis at gmx.de
Fri Feb 5 00:15:02 UTC 2010


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





More information about the core-libs-dev mailing list