> Dependency-checking works fine with javac (e.g. you only need to
> specify x.java as the argument and y.java, if referenced by x.java, is
[quoted text clipped - 4 lines]
>
> Why is that?
> What makes you think it doesn't?
>From Sun:
"If A uses B and B is changed, A.java would not be recompiled unless
explicitly specified. On the other hand, each explicitly passed source
is always recompiled, whether this is really required or not."
(URL: http://www.experimentalstuff.com/Technologies/JavaMake/index.html)
Esmond Pitt - 03 Apr 2007 02:41 GMT
That's not inconsistent with what I said.
Also from Sun:
'javac determines whether the class file is out of date. If the class
file is out of date, javac recompiles the source file and uses the
updated class file. Otherwise, javac just uses the class file.'
That specifically counters your statement 'y.java, if referenced by
x.java, is automatically compiled). However, when y.java is updated and
there is already a file called y.class, y.java is not recompiled.'
The difference might appear subtle but it is there. What javac doesn't
do is chase other classes which are dependent on B (or Y) if B/Y is
recompiled by the rule above. It only explores the dependencies of the
class trees starting at the classes passed in the command line.
[Lars, just repeating this here for the benefit of the NG.]
Mike Schilling - 03 Apr 2007 15:00 GMT
>> What makes you think it doesn't?
>
[quoted text clipped - 3 lines]
> explicitly specified. On the other hand, each explicitly passed source
> is always recompiled, whether this is really required or not."
That's a different statement, though: it describes how dependencies between
*different* classes are handled. It remains true that if javac needs to
process B and notices that B.class is older than B.java, it will compile B.
But if:
* neither A nor B is specicifed on the command line
* the compiler processes class A
* A uses B
* B.java is newer than B.class
* A.class is newer than B.java
then B will be recompiled, but A will not.
The result, whether using Ant to call javac or javac directly is the
following:
o Most of the time, the lazy compilation done by javac works fine.
o On occasion, it doesn't, and the simplest thing to do is delete all of the
class files and recompile the world.