Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Steven Simpson Newsgroups: comp.lang.java.help Subject: Re: IDE suggestion Date: Fri, 01 Mar 2013 12:30:45 +0000 Organization: A noiseless patient Spider Lines: 144 Message-ID: References: <16cce9e6-429a-424a-963b-69a629768a47@googlegroups.com> <2edqv9-7rc.ln1@s.simpson148.btinternet.com> <3io0j8tltj1rivd05uqr3qppd2203rvcou@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: mx05.eternal-september.org; posting-host="3b465170ca8f117fc87b06a457f90e65"; logging-data="31620"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+TRz5PrWjSchKIXeZewh7O8u39RDjqB1E=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130221 Thunderbird/17.0.3 In-Reply-To: <3io0j8tltj1rivd05uqr3qppd2203rvcou@4ax.com> Cancel-Lock: sha1:u5+IyLlUKbqALvZ7ar9hobuSGgE= Xref: csiph.com comp.lang.java.help:2561 On 01/03/13 08:18, Roedy Green wrote: > On Sun, 24 Feb 2013 21:31:14 +0000, Steven Simpson > wrote, quoted or indirectly quoted someone who said : >> I came to the conclusion that Ant is insufficient without an >> error-detecting editor (as in an IDE). If class Foo uses class Bar, >> class Bar could be changed in a way that causes an error in Foo, yet Ant >> will not detect that Foo needs to be recompiled in order to see the >> error, which goes unnoticed until runtime, or until Foo is re-compiled. > I don't think ant has anything to do with it. It just hands all the > source files to javac.exe, and javac.exe makes the decision on what > needs to be recompiled. That only happens if the output directory is included in the classpath. Is Ant invoking javac this way? 'ant -v' shows this: [javac] Compilation arguments: [javac] '-d' [javac] '/scratch/simpsons/Scratch/Coding/antfail2/classes' [javac] '-classpath' [javac] '/scratch/simpsons/Scratch/Coding/antfail2/classes' [javac] '-sourcepath' [javac] '/scratch/simpsons/Scratch/Coding/antfail2/src' [javac] '-g:none' (Note that source files are not listed here, so it's not the complete set of arguments. We can't directly tell which source files are passed from this statement.) The includeDestClasses attribute of controls this, and defaults to "true", though I was also setting it explicitly to its default. I set it to false, and got: [javac] Compilation arguments: [javac] '-d' [javac] '/scratch/simpsons/Scratch/Coding/antfail2/classes' [javac] '-classpath' [javac] '' [javac] '-sourcepath' [javac] '/scratch/simpsons/Scratch/Coding/antfail2/src' [javac] '-g:none' So that attribute does what it says on the tin. I repeated my test run (see end of message) to see if it made any difference. However, again only Bar is recompiled, so Ant is still showing the behaviour I mentioned - javac is only being offered the source files that have changed. > Javac/ANT is so fast compared with what we used to do, loading javac > for each source module and fiddling with MAKE. Certainly, there's no point trying to use Make to pass one file at a time to javac. If you have a dependency sequence A->B->C, and you make a change to B and decide to recompile, C is going to get compiled as an implicit class anyway (unless you add the destination directory to the classpath, which we've already seen misses things), and you might need A compiled anyway. You may as well just compile A if any of the source files for A, B or C have changed. IOW, if it's so fast, just do a clean build every time. Here's the corrected test run... % cat build.xml % cat src/Foo.java public class Foo { public static void main(String[] args) throws Exception { new Bar(); } } % cat src/Bar.java public class Bar { } % ant clean Buildfile: /scratch/simpsons/Scratch/Coding/antfail2/build.xml clean: [delete] Deleting directory /scratch/simpsons/Scratch/Coding/antfail2/classes BUILD SUCCESSFUL Total time: 0 seconds % ant Buildfile: /scratch/simpsons/Scratch/Coding/antfail2/build.xml compile: [mkdir] Created dir: /scratch/simpsons/Scratch/Coding/antfail2/classes [javac] Compiling 2 source files to /scratch/simpsons/Scratch/Coding/antfail2/classes [javac] /scratch/simpsons/Scratch/Coding/antfail2/src/Bar.java [javac] /scratch/simpsons/Scratch/Coding/antfail2/src/Foo.java BUILD SUCCESSFUL Total time: 0 seconds % java -cp classes Foo % sed -e 's/class/abstract class/' -i src/Bar.java % cat src/Bar.java public abstract class Bar { } % ant Buildfile: /scratch/simpsons/Scratch/Coding/antfail2/build.xml compile: [javac] Compiling 1 source file to /scratch/simpsons/Scratch/Coding/antfail2/classes [javac] /scratch/simpsons/Scratch/Coding/antfail2/src/Bar.java BUILD SUCCESSFUL Total time: 0 seconds % java -cp classes Foo Exception in thread "main" java.lang.InstantiationError: Bar at Foo.main(Unknown Source) % touch src/Foo.java % ant Buildfile: /scratch/simpsons/Scratch/Coding/antfail2/build.xml compile: [javac] Compiling 1 source file to /scratch/simpsons/Scratch/Coding/antfail2/classes [javac] /scratch/simpsons/Scratch/Coding/antfail2/src/Foo.java [javac] /scratch/simpsons/Scratch/Coding/antfail2/src/Foo.java:3: error: Bar is abstract; cannot be instantiated [javac] new Bar(); [javac] ^ [javac] 1 error BUILD FAILED /scratch/simpsons/Scratch/Coding/antfail2/build.xml:6: Compile failed; see the compiler error output for details. Total time: 0 seconds -- ss at comp dot lancs dot ac dot uk