diff --git a/WHATSNEW b/WHATSNEW
index 2b9c4127e..b515bea72 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -49,8 +49,10 @@ Other changes:
select files from an archive for extraction. Filesets may be
used to select archived files for unarchival.
-* Javac task allows debug levels to be spcified. Debug levels
- will have an effect only when the modern compiler is used.
+* Javac task allows debug levels to be specified. Debug levels
+ will have an effect only when the modern compiler or the
+ classic compiler (version 1.2 and higher) is used and debugging
+ is enabled.
* Mail task allows specification of port number.
diff --git a/docs/manual/CoreTasks/javac.html b/docs/manual/CoreTasks/javac.html
index 4a0b29065..c60d553ef 100644
--- a/docs/manual/CoreTasks/javac.html
+++ b/docs/manual/CoreTasks/javac.html
@@ -231,10 +231,12 @@ files/directories from the CLASSPATH it passes to the compiler.
debuglevel |
Keyword list to be appended to the -g command line
switch. This will be ignored by all implementations except
- modern , legal values are "none" or a comma separated list of
- the following keywords. Valid keywords are "lines", "vars" and
- "source" - if debuglevel is not specified, by default, nothing will be
- appended to -g
+ modern and classic(ver >= 1.2) , legal values are
+ "none" or a comma separated list of the following keywords.
+ Valid keywords are "lines", "vars" and "source"
+ - if debuglevel is not specified, by default, nothing will be
+ appended to -g . If debug is not turned on, this attribute will be
+ ignored.
|
No |
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 bdd4d6aa0..e323d0e89 100644
--- a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
@@ -262,7 +262,10 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
cmd.createArgument().setValue(encoding);
}
if (debug) {
- if (useDebugLevel) {
+ if (useDebugLevel
+ && Project.getJavaVersion() != Project.JAVA_1_0
+ && Project.getJavaVersion() != Project.JAVA_1_1) {
+
String debugLevel = attributes.getDebugLevel();
if (debugLevel != null) {
cmd.createArgument().setValue("-g:" + debugLevel);
@@ -325,13 +328,17 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
return cmd;
}
+ protected Commandline setupJavacCommand() {
+ return setupJavacCommand(false);
+ }
+
/**
* Does the command line argument processing for classic and adds
* the files to compile as well.
*/
- protected Commandline setupJavacCommand() {
+ protected Commandline setupJavacCommand(boolean debugLevelCheck) {
Commandline cmd = new Commandline();
- setupJavacCommandlineSwitches(cmd);
+ setupJavacCommandlineSwitches(cmd, debugLevelCheck);
logAndAddFilesToCompile(cmd);
return cmd;
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java
index cc413ded7..b99bbd216 100644
--- a/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java
+++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java
@@ -71,14 +71,14 @@ import java.lang.reflect.Method;
*
* @author James Davidson duncan@x180.com
* @author Robin Green greenrd@hotmail.com
- * @author Stefan Bodewig
+ * @author Stefan Bodewig
* @author J D Glanville
*/
public class Javac12 extends DefaultCompilerAdapter {
public boolean execute() throws BuildException {
attributes.log("Using classic compiler", Project.MSG_VERBOSE);
- Commandline cmd = setupJavacCommand();
+ Commandline cmd = setupJavacCommand(true);
OutputStream logstr = new LogOutputStream(attributes, Project.MSG_WARN);
try {