Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppressing Java unchecked warnings in JSP files

I have a legacy webapp which uses jstl and Struts 1 tags. When I pre-compile the JSP files with Java 5/6, the jstl and Struts 1 tags throw warnings about "unchecked or unsafe operations". For example, if I use the following tag:

<%@ page import="/anotherpage.inc" %>

The following warning is thrown:

[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.

If I recompile with -Xlint:unchecked, I get details about the internal working of the offending JSP tag library. I would like to suppress all unchecked operation warnings. I thought that using -Xlint:-unchecked would suppress the warnings, but it did not.

How do I suppress these warnings when compiling my JSP pages? It would not be practical to re-code the JSP tag libraries or update a thousand JSP pages. I'm looking for a compiler flag to globally disable the warning so I can see all warnings except for unchecked warnings. Thanks!

like image 850
Bob Avatar asked Feb 07 '11 19:02

Bob


1 Answers

Those messages are a (mandatory for JDK >= 1.5) note, not a warning.

compiler.note.unchecked.plural=\
    Some input files use unchecked or unsafe operations.

The default compiler behaviour is the same as with -Xlint:-unchecked.

With -Xlint:unchecked you turn the warning on, reporting each instance.

compiler.warn.unchecked.assign=\
    [unchecked] unchecked assignment: {0} to {1}
...

Mandatory notes cannot be disabled individually, they are all disabled with -Xlint:none. Unfortunately, the rest of the warnings are also disabled.

You can check other responses for alternatives, but filtering compiler output messages seems the easiest solution.

like image 159
fglez Avatar answered Oct 26 '22 08:10

fglez