Ignore Compiler Warnings

Let me be upfront, I will be the first person to tell you that you should treat a warning as if it were an error. The compiler is trying to tell you something, it wants to help you. The very smart people who are designing our compiler aren’t identifying code patterns and exposing them as warnings for their health, so come on people … FIX YOUR WARNINGS!

Ok, now that I got that out of the way, we come to the special case. Third party source code generation tools, I actually love generated source, don’t ask me why but I find it much easier to deal with than all the mucking around you could do in meta-code etc. Just give me a plain ‘ol class that I can use. The drawback to generated source is some of the generators are pretty rough when it comes to warnings. They might have unneeded imports, referenced untyped classes, who knows. We all can agree that it would be optimal if the generators would just produce warning free code, and if it is in your power join up with some of these open-source projects and actually fix them (you’d be my hero).

When that isn’t an option I’d just ignore them, I’m adding an ant task that can read in a fileset and append warning suppression annotations to the class headings. Just remember you have not fixed anything, but to be perfectly practical you may never fix these things.

Updated 4/13/1013
Download Jar File: suppresswarnings-0.6.jar

Usage:

<taskdef resource=”suppresswarnings.properties” classpath=”${suppresswarnings.jarfile}”/>

<fileset dir=”${src.dir}”> <include name=”*\*/\*.java”/> </fileset>