I call javac from my ant script like this:
You cannot do that: Neither from the command line, so you cannot do it from Ant either.
The javac documentation says:
-Xlint:none
Disable all warnings not mandated by the Java Language Specification.
So it seems this kind of warning cannot be suppressed, because they are raised by the JLS directly.
What you can do is to:
@SuppressWarnings({"deprecation"}, {"unchecked"})
at the required positions/dev/null
-Xlint:-unchecked -Xlint:-deprecation
arguments, maybe it is only an Ant-related issue.adding the -XDignore.symbol.file
option to the javac
command line worked for me.
To prevent deprecation warnings I tried to do it using JDK 6 and JDK 7.
With JDK 7, @Deprecated
annotation does the work
With JDK 6, it does not work, neither adding -Xlint:-deprecation
param works for me. The only way I managed to remove the warning was using the @deprecated
Javadoc Tag:
/**
* @deprecated
*/
@Override
public void removeValue(String arg0) {
// TODO Auto-generated method stub
}
use nowarn attribute see below
e.g.
<javac srcdir="src"
destdir="build/classes" source="1.6"
target="1.6" debug="true" encoding="Cp1252"
nowarn="on">
by default nowarn attribute is off
The best way to do this is to use the sunapi
suppression, i.e. either -Xlint:-sunapi
for the entire compile, or @SuppressWarnings("sunapi")
at your required scope.
Note, the only way to use this suppression though, is to first enable it with the compiler option -XDenableSunApiLintControl
enableSunApiLintControl
Recommendation: Don't ignore your compiler's warnings. The warnings are there for a reason. My company's legacy codebase is moving towards a "treat warnings as errors and fail the build" model as we can expend the effort to fix warnings produced during our compile cycle.
In your case, the warning is:
warning: sun.reflect.Reflection is Sun proprietary API and may be removed in a future release
It has always been a warning to not import from sun
packages as long as I can remember, because they're a non-public API. There's even a FAQ about it on the official Oracle Java site.
You haven't posted your actual code, so it's hard to provide further recommendations...What are you using in sun.reflect.Reflection
that you couldn't also do through something in java.lang.reflect
?