Warnings Cleanup in java.util. (more from hack day) (original) (raw)

Doug Lea dl at cs.oswego.edu
Fri Dec 2 16:30:46 PST 2011


On 12/02/11 19:16, John Rose wrote:

Presently we are aiming at removing warnings with no changes to semantics (i.e., bytecodes).

Note that this is at odds with suggestions such as:

java/util/Currency.java --

The @SuppressWarnings covers the entire method. We're trying to use @SuppressWarnings with as narrow a scope as possible. Sometimes it's helpful to create a local variable declaration for this purpose; perhaps something like this will help: @SuppressedWarnings("unchecked") Set result = (Set) available.clone(); return result;

This generates two more bytecodes and a local variable. This won't matter when the code is actually JIT-compiled, but the increased size might inhibit inlining or compilation. Surely it doesn't matter in this class, but we are very careful about these and many related issues in performance-sensitive java.util.concurrent code.

Too bad you cannot place annotations on expressions.

Also too bad that javac doesn't do trivial optimizations.

-Doug



More information about the jdk8-dev mailing list