Hiding deprecation warnings

Hey guys,

I am a current Netbeans user trying out IntelliJ Community Edition 11.1 to see if I want to move across. I've been having a few problems though, one of which is with compile warnings. I wanted to disable only the deprecation and serial UID warnings, so I went to the Compiler options in settings and put  -Xlint -Xlint:-deprecation  -Xlint:-serial into the command line parameters. However, this seems to get ignored, as when I compiled I still had the warnings. In fact, I can even tick the "Generate No Warnings" box and still get them.

Would appreciate any hints.

Comment actions Permalink

Welcome to the IntelliJ IDEA forums.

What results do you get when you compile directly from the command line with those options? I get the same results from the command line as I do from IDEA. This indicates it is not an issue with IDEA. And if I pass in an invalid parameter, I get an error. This shows that IDEA is passing the parameters to the compiler. Some things to keep in mind. 1) compile warning suppression can vary from compiler implementation to implementation (for example between the Sun compiler and the IBM compiler.) Is the project in NetBeans using the same compiler?  2) It's possible that NetBeans was intercepting those warnings and not displaying them via some configuration option. See belwo for how to do this in IDEA. 3) The option -Xlint:none (a.k.a -nowarn) does not suppress all warnings, only some.  Per the javac documentation:

Non-Standard Options

Disable all warnings not mandated by the Java Language Specification.

I beleive the "Gnerate no warnings" option in the compiler settings is just a convenience setting for the -Xlint:none option and therefore is subject to its rules. If you do not want the warnings to show in IntelliJ IDEA when you compile, after compiling once, click the "Hide Warnings" icon Hide_Warnings.png on the Messages tool window. That will hide the warnings for the current build and for subsequent buillds. The setting will be retained upon restarts.

Another option for you would be to use the @SuppressWarning annotation in the code. To easily add this using IDEA:

  1. place your cursor on the deprecated code
  2. type Alt+Enter
  3. in the popup, highlight the options listing for the inspection responsible for the warning (for example "Inspection 'Deprecated API Usage' options")
  4. Hit the right arrow
  5. From the secondary popup, select one of the suppress options such as "Suppress for Statement", "Suppress for Method", or "Suppress for Class"
  6. Hit enter

I hope that helps.

Comment actions Permalink

Thanks, I got round to testing this on the command line and other IDEs today as a comparison.

There does seem to be some small differences, such as NetBeans not looking at tests for compile warnings, but the response to Xlint arguments does seem consistent


Please sign in to leave a comment.