Suppressing Java unchecked warnings in JSP files

给你一囗甜甜゛ 提交于 2019-12-01 15:27:34

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.

You are right that

-Xlint:unchecked

does the opposite of what you want, but you can also use

-Xlint:-unchecked

Note the extra "-" in there.

This will disable all warnings about unchecked operations, not just the ones generated by the tag library, but other warnings will still be shown.

the best way to disable that warning is to stop using Java code in your JSPs. Start getting used to using JSTL or JSF instead (with custom tag libs as needed).

But with legacy applications you're not going to be able to do that most likely, and you'll just have to live with the warnings. Of course you can add the -nowarn flag to the compiler, but this will disable ALL warnings, not just this one, which may be more than you want.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!