Bug 30716 - javac task fails to recompile java files that have external dependencies
Summary: javac task fails to recompile java files that have external dependencies
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.7.0
Hardware: All All
: P2 major with 2 votes (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-17 22:00 UTC by Alon Albert
Modified: 2010-04-15 17:31 UTC (History)
0 users



Attachments
Simple test suite for testing javac ant task. (3.44 KB, application/zip)
2010-04-15 17:14 UTC, Jacob Abrams
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alon Albert 2004-08-17 22:00:38 UTC
The javac task has an annoying limitation that causes many users to have to run 
clean before building a slightly updated project.

This is because javac task only compiles out dated files but it isn't very 
clever about dependancies. It simply maps a *.java file against a *.class file. 
There exists an optional ant task called depend that is smarter about this. It 
detects real dependancies by digging into the class file themselves.

Running the depend task before the javac task will resolve the issue but most 
people arn't aware of this. Also, having to specify the srcdir & destdir twice 
can be a source for errors.

Rather, javac task should utilize the existing code found in depend task to 
build a proper outdated list.
Comment 1 Jacob Abrams 2010-04-15 17:14:29 UTC
Created attachment 25305 [details]
Simple test suite for testing javac ant task.
Comment 2 Jacob Abrams 2010-04-15 17:20:37 UTC
I believe this is more than just an enhancement request, it is actually a bug. I don't think these two situations should ever produce different results:

1. calling javac with a destination directory that contains some previously compiled .class files
2. calling java with an empty destination directory

If these produce different results then no programmer will ever trust existing .class files and will want to clean them every time.

Please see the attached test suite that demonstrates the issue, just change the int value in R.java to something else and run:

1. ant compile
2. ant run

Notice that the change never takes effect, but if you do the following it does:

1. ant clean
2. ant compile
3. ant run

This is because static final integers are copied into the class files using them, even if those class files don't change they need to be recompiled if the int does. The simple algorithm used by ant to determine dependency is causing this problem and should be eliminated.