On 11/29/11 8:10 AM, Alan Bateman wrote:
I don't have time on Thursday to get involved in the warnings fest [1]. However
I would like to contribute something and to that end the following webrev
proposes changes to eliminate the warnings from several classes including
java.rmi.**, the serialization classes, and several core classes:
http://cr.openjdk.java.net/~alanb/7116404/webrev/
Wow, you're getting a jump on us! Any idea how many warnings this cleared up?
Looks like dozens.
The changes are mostly trivial, and mostly to raw type usages. One tricky one
ObjectInputStream.readEnum where I had to use a raw type (Maurizio and I
chatted about this one and there doesn't seem to be a better workaround). There
is one non-warnings change in java.rmi.server.LogStream where I replaced a
usage of legacy Hashtable with a HashMap.
A couple comments on these:
* The ObjectInputStream.readEnum case does indeed look tricky and so use of
@SuppressWarnings is probably called for. Is it possible to use this annotation
in a smaller scope than the entire method? In Effective Java, Josh Bloch
recommends putting @SuppressWarnings on a declaration, even creating a new
local variable if necessary. (He also recommends adding a comment.) Perhaps
it's possible do to this here; while a local declaration within a try-block
seems redundant, but it might enable narrowing the scope of @SuppressWarnings
considerably.
* Similar comment on java/rmi/MarshalledObject.get(). Looks to me like the only
unchecked warning in there is at (old) line 159, which is a declaration, so
@SuppressWarnings could be placed there instead of on the entire method.
Thanks.
s'marks
-Alan.
[1] http://mail.openjdk.java.net/pipermail/jdk8-dev/2011-November/000302.html