On 11/15/12 3:06 AM, Alan Bateman wrote:
On 14/11/2012 22:44, Chris Hegarty wrote:
- @SuppressWarnings("unused")   Eclipse???
   Do we have precedent for adding these suppressions??

I don't see it in the -Xlint options that javac supports so it might be
specific to ECJ. I recall this topic came up during one of the warnings
clean-up days, Stuart might remember the outcome.

Yes, I gave an (Oracle internal) tech talk on warnings cleanup some time back where I mentioned this issue. I'll repeat the results here for everybody's benefit.

The background is that the words that can be supplied to @SuppressWarnings reside in an uncontrolled namespace. The JLS [1] defines only "unchecked" and any others are compiler-specific. The set of words accepted here by javac is the same as the words defined for -Xlint.

I did a survey of the sources in the jdk repo and found that the javac-defined warnings suppression tags were:

    deprecation fallthrough rawtypes serial try unchecked

In addition, I found the following non-javac tags used:

    all
    empty-statement
    unused
    LeakingThisInConstructor
    OverridableMethodCallInConstructor
    ResultOfObjectAllocationIgnored
    SleepWhileHoldingLock
    UnnecessaryLocalVariable

I actually have no idea which tool processes these. The names are suggestive though. I don't think we ever determined any policy about which names ought to be used in the OpenJDK code base. At the very least I think any of the javac -Xlint words is acceptable. I could be convinced that allowing others is a good idea (such as the Eclipse ones) if they're useful and a definition is available somewhere.

s'marks


[1] http://docs.oracle.com/javase/specs/jls/se7/html/jls-9.html#jls-9.6.3.5

Reply via email to