Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Why does javac not check timestamps?

Thread view: 
Lars Andersson - 01 Apr 2007 23:10 GMT
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
automatically compiled).

However, when y.java is updated and there is already a file called
y.class, y.java is not recompiled.

Why is that? Wouldn't it be trivial to add that feature to javac and
make advanced build tools unneccessary?
visionset - 02 Apr 2007 00:28 GMT
> 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 - 5 lines]
> Why is that? Wouldn't it be trivial to add that feature to javac and
> make advanced build tools unneccessary?

What about all the other none java sourcecode resources that change during
development?
I can't see me ever using anything other than Ant or the likes for anything
more than trivial.  You should check out Ant, I don't know anyone who isn't
an instant convert.  You get so much with such little complexity.

Signature

Mike W

ivan danicic - 02 Apr 2007 11:09 GMT
>> 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 - 3 lines]
>> y.class, y.java is not recompiled.
> snip
Hello, I have been caught out by this. If x is the main class and y uses x
but not vice versa, directly or indirectly, then updating y and compiling x
does no good. In complicated cases it's not easy to determine what will
happen.
Ivan
Esmond Pitt - 02 Apr 2007 04:24 GMT
> 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 the documentation for 'javac': 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.
Lars Andersson - 02 Apr 2007 19:25 GMT
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.