When pre-compiling JSPs with the Jasper compiler (using Tomcat), and then the Java compiler I see javac
warnings like this (I have javac
's -Xlint
flag enabled):
warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.List
_jspx_dependants.add("/some-jsp.jspf");
Now, it's "just a warning," but I like clean builds, so naturally I want to get rid of the warning. Sure, I could turn -Xlint
off for JSP compilation, but -Xlint
is good stuff, so it stays.
In this example warning, the problem is that generic syntax isn't used. Instead of List<String>
, we have only List
. I realize that the good folks who write Jasper have to cater to those unfortunate souls who remain locked in a pre-Java5 world. That's fine, but why should I have to suffer these warnings?
Is there some well-known way to eliminate javac warnings caused by the Java source code created by the Jasper JSP compiler? I'm not interested in an IDE-specific solution (though that would be a partial solution for some people who use the particular IDE). I'm looking for a generally applicable solution.
A scan of the Jasper source code didn't reveal any "Java 5+" switches that would cause generic syntax emission. In fact, on the contrary I found this:
apache-tomcat-6.0.18-src/java/org/apache/jasper/compiler/Generator.java:494: out.printin("_jspx_dependants = new java.util.ArrayList(");
which clearly shows the hardcoded code bereft of any hope for injection of elegant generic syntax.