diff --git a/WHATSNEW b/WHATSNEW
index d85a9e993..53b1ece94 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -194,6 +194,9 @@ Other changes:
* has a new strict attribute that checks if the jar complies with
the jar packaging version specification.
+* has a new attribute - includeDestClasses.
+ Bugzilla 40776.
+
Changes from Ant 1.6.5 to Ant 1.7.0
===================================
diff --git a/docs/manual/CoreTasks/javac.html b/docs/manual/CoreTasks/javac.html
index c555011a8..e3eb6ea23 100644
--- a/docs/manual/CoreTasks/javac.html
+++ b/docs/manual/CoreTasks/javac.html
@@ -403,6 +403,29 @@ invoking the compiler.
No |
+
+ includeDestClasses |
+
+ This attribute controls whether to include the
+ destination classes directory in the classpath
+ given to the compiler.
+ The default value of this is "true" and this
+ means that previously compiled classes are on
+ the classpath for the compiler. This means that "greedy" compilers
+ will not recompile dependant classes that are already compiled.
+ In general this is a good thing as it stops the compiler
+ for doing unnecessary work. However, for some edge cases,
+ involving generics, the javac compiler
+ needs to compile the dependant classes to get the generics
+ information. One example is documented in the bug report:
+
+ Bug 40776 - a problem compiling a Java 5 project with generics.
+ Setting the attribute to "false" will cause the compiler
+ to recompile dependent classes.
+ Since Ant 1.7.1.
+ |
+ No - default is "true" |
+
Parameters specified as nested elements
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java
index 4840e11d3..30b1be585 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Javac.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java
@@ -116,6 +116,7 @@ public class Javac extends MatchingTask {
private String updatedProperty;
private String errorProperty;
private boolean taskSuccess = true; // assume the best
+ private boolean includeDestClasses = true;
/**
* Javac task for compilation of Java files.
@@ -817,6 +818,25 @@ public class Javac extends MatchingTask {
this.errorProperty = errorProperty;
}
+ /**
+ * This property controls whether to include the
+ * destination classes directory in the classpath
+ * given to the compiler.
+ * The default value is "true".
+ * @param includeDestClasses the value to use.
+ */
+ public void setIncludeDestClasses(boolean includeDestClasses) {
+ this.includeDestClasses = includeDestClasses;
+ }
+
+ /**
+ * Get the value of the includeDestClasses property.
+ * @return the value.
+ */
+ public boolean isIncludeDestClasses() {
+ return includeDestClasses;
+ }
+
/**
* Get the result of the javac task (success or failure).
* @return true if compilation succeeded, or
diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
index 4884f28de..866b987e4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
@@ -137,7 +137,7 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
// add dest dir to classpath so that previously compiled and
// untouched classes are on classpath
- if (destDir != null) {
+ if (destDir != null && getJavac().isIncludeDestClasses()) {
classpath.setLocation(destDir);
}
diff --git a/src/tests/antunit/taskdefs/javac-test.xml b/src/tests/antunit/taskdefs/javac-test.xml
index 656580445..240dfa581 100644
--- a/src/tests/antunit/taskdefs/javac-test.xml
+++ b/src/tests/antunit/taskdefs/javac-test.xml
@@ -2,8 +2,43 @@
-
+
+
+
+
+
+
+
+ public class A { B b;}
+
+
+ public class B { }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+