The following is a list of most of the valid @suppresswarning annotation parameters in Java for Eclipse and IBM RAD IDE. The right column shows what those java annotation parameters are used for.
|
Annotation Param |
Usage |
| intfNonInherited | interface non-inherited method compatibility |
| javadoc | invalid javadoc |
| localHiding | local variable hiding another variable |
| maskedCatchBlocks | hidden catch block |
| nls | to suppress warnings relative to non-nls string literals |
| noEffectAssign | assignment with no effect |
| null | to suppress warnings relative to null analysis |
| nullDereference | missing null check |
| over-ann | missing @Override annotation |
| paramAssign | assignment to a parameter |
| pkgDefaultMethod | attempt to override package-default method |
| raw | usage a of raw type (instead of a parametrized type) |
| restriction | to suppress warnings relative to usage of discouraged or forbidden references |
| semicolon | unnecessary semicolon or empty statement |
| serial | to suppress warnings relative to missing serialVersionUID field for a serializable class |
| specialParamHiding | constructor or setter parameter hiding another field |
| static-access | to suppress warnings relative to incorrect static access |
| staticReceiver | if a non static receiver is used to get a static field or call a static method |
| super | overriding a method without making a super invocation |
| suppress | enable @SuppressWarnings |
| synthetic-access | to suppress warnings relative to unoptimized access from inner classes |
| tasks | enable support for tasks tags in source code |
| typeHiding | type parameter hiding another type |
| unchecked | to suppress warnings relative to unchecked operations |
| unnecessaryElse | unnecessary else clause |
| unqualified-field-access | to suppress warnings relative to field access unqualified |
| unused | to suppress warnings relative to unused code |
| unusedArgument | unused method argument |
| unusedImport | unused import reference |
| unusedLabel | unused label |
| unusedLocal | unused local variable |
| unusedPrivate | unused private member declaration |
| unusedThrown | unused declared thrown exception |
| uselessTypeCheck | unnecessary cast/instanceof operation |
| varargsCast | varargs argument need explicit cast |
| warningToken | unhandled warning token in @SuppressWarnings |
Here is an usage example. As you can see, the piece of code below does not use any annotations and the code has a yellow underline in the method signature. If you hover around the icon on the left bar of the IDE where there will be warning sign, you will notice that the Eclipse IDE has issued warning saying that this method is never called in the class.

But if you put the annotation @SuppressWarning(“unused”), we specifically tell the IDE to ignore the usused methods by suppressing the warnigns. Here is the code after the annotation has been added. Code looks clean, no more annoying warning underline !
Originally posted 2012-06-25 20:10:38.
