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 ???
I don't see a big advantage for casting to (Class<?>) against (Class)
for the cache of Converters.java.
Rules for Class<?> and Class are not the same.
Class should be only used when dealing with legacy code.
One of the advantages of generics is the avoidability of casts.
So I wanted to say, if a code becomes reengineerd in generic way, then
it should be done in "full way".
-Ulf
P.S.: Additionally note:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6853699