Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: How to turn off those warning messages during ant build? Date: Wed, 4 Apr 2012 10:54:56 -0700 (PDT) Organization: http://groups.google.com Lines: 72 Message-ID: <14865168.2734.1333562096706.JavaMail.geo-discussion-forums@pbje9> References: <32649009.2052.1333546152596.JavaMail.geo-discussion-forums@vbsf4> NNTP-Posting-Host: 69.28.149.29 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1333563717 10026 127.0.0.1 (4 Apr 2012 18:21:57 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 4 Apr 2012 18:21:57 +0000 (UTC) In-Reply-To: <32649009.2052.1333546152596.JavaMail.geo-discussion-forums@vbsf4> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Received-Bytes: 3781 Xref: csiph.com comp.lang.java.programmer:13383 zyng wrote: > When I run ant, a lot of warnings are printed out on the screen. It is very daunting. It makes The warnings you cite are due to errors in your coding. > new people to feel, as first response, this is broken. But actually, the build is successful. > I pasted a few warning messages below. In our real code, there are hundreds of them. > > [javac] /abc/efg/MyTools.java:125: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.List > [javac] recursiveDirectoriesToBuild.add(workingDir); Don't use raw types! That's an invitation to runtime bugs. Generics are there to pull these bugs back to compilation time, thus making them four to sixteen times cheaper to fix than if they were runtime bugs. Do not use raw types. > [javac] ^ > [javac] /abc/efg/MyTools.java:212: warning: [unchecked] unchecked call to Vector(java.util.Collection) as a member of the raw type java.util.Vector > [javac] return new Vector(v2); Why are you using 'java.util.Vector' instead of, say, 'java.util.ArrayList'? > .... > > I know one solution, the basic solution, is to going to the code and use Java Annotation > feature to add "Ignore Warning etc" at those places. That's not a solution! That hides the problem without fixing it. There are rules to using '@SuppressWarnings("unchecked")'. You don't just use the annotation to hide problems. > But there are so many places and the code were written by different people. This is called "technical debt", and it is an issue. > We don't want to modify the code! I am wondering if ant has a feature to turn off the warning messages. 'javac' does. That's more relevant because Ant isn't the one issuing the warnings. "-Xlint:-rawtypes" This is bad because it hides the problem without fixing it. You should familiarize yourself with the Java tools. http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/javac.html#xlintwarnings > > This is my ant script to build: > > > > "-Xlint:what"? All you do with that option is: "Enable all recommended warnings. In this release, enabling all available warnings is recommended." As mentioned in the documentation for "javac", which you should study. > > > > To be honest, I do not know the feature "-Xlint" etc. To be honest, shame on you. RTFM. -- Lew