Update July 2011: This list has been reviewed and made current with the most recent Eclipse 3.7 release.
If you are a Java developer and use the new @SuppressWarnings annotation in your code from time-to-time to suppress compiler warnings you, like me, have wondered probably about a million times already just exactly what are the supported values that can be used with this annotation.
The reason the list isn’t easy to find is because it’s compiler specific, which means Sun may have a different set of supported values than say IBM, GCJ or Apache Harmony.
Fortunately for us, the Eclipse folks have documented the values they support (as of Eclipse 3.7), here they are for reference:
- all to suppress all warnings
- boxing to suppress warnings relative to boxing/unboxing operations
- cast to suppress warnings relative to cast operations
- dep-ann to suppress warnings relative to deprecated annotation
- deprecation to suppress warnings relative to deprecation
- fallthrough to suppress warnings relative to missing breaks in switch statements
- finally to suppress warnings relative to finally block that don’t return
- hiding to suppress warnings relative to locals that hide variable
- incomplete-switch to suppress warnings relative to missing entries in a switch statement (enum case)
- nls to suppress warnings relative to non-nls string literals
- null to suppress warnings relative to null analysis
- rawtypes to suppress warnings relative to un-specific types when using generics on class params
- restriction to suppress warnings relative to usage of discouraged or forbidden references
- serial to suppress warnings relative to missing serialVersionUID field for a serializable class
- static-access to suppress warnings relative to incorrect static access
- synthetic-access to suppress warnings relative to unoptimized access from inner classes
- unchecked to suppress warnings relative to unchecked operations
- unqualified-field-access to suppress warnings relative to field access unqualified
- unused to suppress warnings relative to unused code
TIP: For the folks that haven’t used @SuppressWarnings before, the syntax looks like this:
@SuppressWarnings(“unused”)
and can be placed above almost any piece of code that is causing a compiler warning to popup for your class.
Update #1: Thanks to Pierre for the addition of the ‘rawtypes’ argument and description.

Thanks! Been lookin’ for that!
No problem, glad it helped!
I couldn’t believe how hard it was to find a list when I originally went looking, so I knew I had to blog it
Wow, thats super cool
cool. thanx a bunch to folks who got this online
Thanks for this list
No problem, glad it could help! (I know that I just keep this page bookmarked any time I’m coding now, they really should just add this to the auto-complete list in the editor IMO… or some agreed up on sub-set between Eclipse JDT/Sun Javac or something…)
Wow – thx: likewise, can’t believe how hard this is to find …
Big Thanks for the list! looked and found your blog
Paulo, glad it helped!
Rock. Thanks!
Thanks. For your information
Thanks for your valuable information
PRK,
Not a problem, glad it helped!
Thanks Riyad, your article just helped me out. Much appreciated!
Glad to hear it Cyrus!
This really is a great blog to have put up. Thanks a lot for making this list public, it’s very useful now that I have just started learning about and using SuppressWarnings.
Man, so useful.
Thanks Riyad for this very useful information.
thx riyad, this is so useful
Hi Riyad, there is one missing value for @SuppressWarnings you didn’t talked about:
@SuppressWarnings (“rawtypes”)
It helps you with generic classes when you don’t want them to have a parameter.
Pierre, thanks for the heads up. I’ll add it to the article.
Great list, thanks.
BTW, this blog post is the second result when searching for SuppressWarnings on Google, that’s how i reached here.
medopal, glad it helped! That’s all I wanted to create, a quick-reference so people didn’t have to dig and dig.
Hi Riyad,
Do you know maybe how to apply @SuppressWarnings(“null”) on a method parameter? Does it work at all?
Thanks for a help.
Przemek, I think you can… atleast I don’t get compile errors in IJ for this:
@SuppressWarnings(“null”) String guid
Have you given it a try?
Yes, I already have but it didn’t work. In addition to that I am getting the warning “Unnecessary @SuppressWarnings(“null”)” under eclipse.
Dummy example that I have tried.
public void test(@SuppressWarnings(“null”) String text) {
if (text == null) {
text.length();
}
}
Przemek, what warning are you trying to suppress with that annot btw? Maybe there is a misunderstanding about how these work?
From the code snippet you posted, I made me think what you *want* is a way to specify that an arg is NotNull, much like JSR 305 is trying to do with @NotNull and a few other annots (click here for more info)
And that’s not what @SuppressWarnings will do — it just tells the compiler to “shut it” when it comes to certain warnings, and in the case above, the compiler won’t emit a warning for ‘text’ potentially being null, so that annot is actually a no-op.
By text.length() I am getting the warning “Null Pointer Access” which I want to suppress. You are right. @NotNull would solve the issue. In the real system however I am currently working on the snippet would look a bit different (@NotNull is not at stake):
public void test(String text) {
Assert.isTrue(text != null && text.length() > 0, “Error”);
text.length();
}
where Assert.isTrue (not JUnit-Assert) throws AssertException where the condition is not met. The compiler doesn’t recognize that by the line with text.line() text cannot be null anymore. So it shows “Potential Null Pointer Access”. This is in fact what I want to suppress.
Ahhh… does the SuppressWarning annot do what you want when you throw it on the entire method and not just the parameter?
This is in Eclipse right? I wonder if you are spending more time than it’s worth fighting the Eclipse Java compiler to do what you want instead of just turning off the “might be null” warning directly on the compiler settings prefs page?
I don’t think javac shows this warning by default, but the Eclipse compiler might. Not sure.
Right. On the method level @SuppressWarnings works perfectly but doing this would be too wide.
Right. It’s possible to turn (P)NPA check off in eclipse compiler settings. I would like to avoid it as well. The (P)NPA warning is useful but often gives false alarms. I would like to switch it off case by case.
I thought @SuppressWarnings(“null”) would solve the problem as it can be inserted at method parameter level.
I also like the RedundantIfStatement suppression in IntelliJ for handling generated equals() methods so that it doesn’t force you to “simplify” the equals expression to be a one-line command.
Even after 4 years this list helps some people like me.
Thank you!!