ant javac Xlint:unchecked
You are porting your code to Java 5.0 (aka 1.5); building your project under Xcode gives the following notes from javac:
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
This raises the following question:Q: How do I pass
-Xlint:unchecked
to an ant javac task? A: Edit the relevant target in your
build.xml
file to add an embedded compilerarg
entry, to the javac task: <compilerarg value="-Xlint:unchecked"/>
or
<compilerarg value="-Xlint"/>
so it reads something like this:
<target name="compile" description="Compile code">
<mkdir dir="${bin}"/>
<mkdir dir="${lib}"/>
<javac srcdir="${src}" destdir="${bin}"
includeAntRuntime="no"
classpathref="lib.path"
debug="${compile.debug}">
<compilerarg value="-Xlint"/>
</javac>
</target>
Using "-Xlint"
enables all recommended Xlint options, including :unchecked
. See the Sun javac documentation (scroll down to Xlint) for details of other options, giving finer control if you need it.
8 comments:
This blog is a godsend.
Really useful blog...
I was just searching for that option...
so, javac uses 1.5 by default if we have both 1.5 and 1.4 is it?
My question is, what if I want to say javac -source 1.5?
Köszi a segítséget!
Thanks!
thanks !
Fantastic!
This is not a Mac OS tip, but a java developer tip, thanks.
Post a Comment