Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #2561

Re: IDE suggestion

From Steven Simpson <ss@domain.invalid>
Newsgroups comp.lang.java.help
Subject Re: IDE suggestion
Date 2013-03-01 12:30 +0000
Organization A noiseless patient Spider
Message-ID <lkj60a-lof.ln1@s.simpson148.btinternet.com> (permalink)
References <kgcs9j$epe$1@dont-email.me> <nospam-BAA3EA.15005124022013@news.aioe.org> <16cce9e6-429a-424a-963b-69a629768a47@googlegroups.com> <2edqv9-7rc.ln1@s.simpson148.btinternet.com> <3io0j8tltj1rivd05uqr3qppd2203rvcou@4ax.com>

Show all headers | View raw


On 01/03/13 08:18, Roedy Green wrote:
> On Sun, 24 Feb 2013 21:31:14 +0000, Steven Simpson <ss@domain.invalid>
> 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 <javac> 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
<project default="compile">
   <target name="compile">
     <mkdir dir="classes" />
     <javac srcdir="src" destdir="classes"
            listfiles="yes" includeDestClasses="false"
            includeAntRuntime="false" />
   </target>

   <target name="clean">
     <delete dir="classes" />
   </target>
</project>
% 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

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

IDE suggestion "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-24 11:08 +0000
  Re: IDE suggestion "John B. Matthews" <nospam@nospam.invalid> - 2013-02-24 15:00 -0500
    Re: IDE suggestion Lew <lewbloch@gmail.com> - 2013-02-24 12:23 -0800
      Re: IDE suggestion "Schizoid Man" <schiz_man@21stcentury.com> - 2013-02-24 20:40 +0000
        Re: IDE suggestion Lew <lewbloch@gmail.com> - 2013-02-24 14:51 -0800
        Re: IDE suggestion Roedy Green <see_website@mindprod.com.invalid> - 2013-02-25 11:27 -0800
      Re: IDE suggestion Steven Simpson <ss@domain.invalid> - 2013-02-24 21:31 +0000
        Re: IDE suggestion Roedy Green <see_website@mindprod.com.invalid> - 2013-03-01 00:18 -0800
          Re: IDE suggestion Steven Simpson <ss@domain.invalid> - 2013-03-01 12:30 +0000
            Re: IDE suggestion Roedy Green <see_website@mindprod.com.invalid> - 2013-03-09 17:35 -0800
              Re: IDE suggestion Steven Simpson <ss@domain.invalid> - 2013-03-10 09:09 +0000

csiph-web