Excluding warnings using @SuppressWarnings

Since Java 5.0, you can disable compilation warnings relative to a subset of a compilation unit using the java.lang.SuppressWarning annotation.

 @SuppressWarning("unused") public void foo() {
  String s;
 }

Without the annotation, the compiler would complain that the local variable s is never used. With the annotation, the compiler silently ignores this warning locally to the foo method. This enables to keep the warnings in other locations of the same compilation unit or the same project.

The list of tokens that can be used inside a SuppressWarnings annotation is: