When I compile the Spring JDBC source on OS X with JDK 1.7.0, I get this warning:
warning: CachedRowSetImpl is internal proprietary API and may be removed in a future release
How do I suppress the warning message during a compile?
I already know and use Java's @SuppressWarning annotations. I'm looking for the specific use of this to suppress the warning I've described.
My question specifically is, in this line of code:
@SuppressWarnings("valuegoeshere")
what should "valuegoeshere" be replaced with?
EDIT: People, I know that it is best to avoid the code that leads to the warning. And usually that would be my approach. However I'm compiling third-party code here which I don't want to rewrite. I just want to add the correct annotation to suppress the warning, so that warnings I can actually do something about don't get buried.
If you are using maven, you might be interested in adding the following to your
pom.xml
file:This particular warning cannot be suppressed. At least not officially.
If you're particularly determined, you can use the highly undocumented
javac -XDignore.symbol.file
flag which will compile your program against Sun's internalrt.jar
rather than the public-facing symbol filect.sym
.rt.jar
doesn't produce this warning.see this answer
Testing code
compiling command line
or
compile passed with no any warning
remove the
SuppressWarnings
tag and compile againan error is reported then
I tried
but that didn't work.
So I resorted to a horrible, horrible kludge which I don't recommend in general, but in this specific case made the warning go away. I used reflection to instantiate a new instance of the com.sun.rowset.CachedRowSetImpl class.
I replaced this line, which caused the warning:
with this block:
Please don't do this in your own code without first considering any other option.
Try the javac option
If you compile from an IDE, it should have an option to disable warnings.
This will disable ALL warnings that are not a part of Java Language Specification. So for example "unchecked" warning will not be blocked.
Reference its interface CachedRowSet not the implementation.