Crouchez wrote On 09/05/07 15:15,:
Crouchez wrote On 09/05/07 13:21,:
What is this with javac -Xlint??
warning: [unchecked] unchecked call to put(K,V) as a memb
er of the raw type java.util.HashMap
headers.put(key,val);
^
http://java.sun.com/docs/books/tutorial/java/generics/index.html
I'm trying to stay away from Generics. Is it really worth that extra coding
effort? It makes you're code look ugly as well.
Aesthetics aside, your attempt to stay away from
generics has already failed: The Collection framework
has been generified, and the warning message you've
received means your code hasn't kept pace. As I see
it, you have various possible recourses:
- Revert to a pre-1.5 Java environment. This will
become untenable when 1.4 reaches end-of-life,
which (IIRC) will be before the USA elects its
next President.
- Add annotations (another 1.5 feature; see the
Tutorial) to suppress the warnings. This will
require extra caution on your part, because a
ClassCastException will make you look reckless
instead of just unfortunate.
- Get rid of -Xlint and ignore the warnings that
still remain. See above.
- Adopt generics in your own code, at least to
the extent of catering to them in other classes
that are already generified. Who knows? You
might grow accustomed to them, even if they
never arouse your adoration.
The choice isn't mine to make.