ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Wolfe" <>
Subject 'java' ant task not displaying debug info
Date Tue, 06 Apr 2004 21:10:58 GMT
I've posted on this before, but got no response so I've devised a simple test case that demonstrates
the problem.

When I compile with the 'javac' task in ant with 'debug' set to true, debug information is
in the class file which is produced.  I can verify this by running 'java' from the command
line.  However, when I run the 'java' ant task, debug information is not shown.  I'm running
ant version 1.5.2-23

I would appreciate it if people can try out this program and report if they get the same result.

-Greg Wolfe

running from ant:

$ ant
Buildfile: build.xml
    [mkdir] Created dir: /home/gwolfe/msrc/emp/sample/build
    [javac] Compiling 1 source file to /home/gwolfe/msrc/emp/sample/build
     [java] Example String
     [java] Exception in thread "main" java.lang.Exception: This exception should log the
line number
     [java]    at Example.main(java.lang.String[]) (Unknown Source)
     [java] Java Result: 1
Total time: 0 seconds

==> note the "Unknown Source" in the output.

running java from the commandline:
$ cd build; java Example; cd ..
Example String
Exception in thread "main" java.lang.Exception: This exception should log the line number
        at Example.main(

==> note that debug information is available

 * Demo program to check if debug is enabled
 * @author Greg Wolfe
public class Example {
    public Example(String message) {
        this._message = message;
    public String getMessage() {
        return _message;
    public static void main(String[] args) throws Exception {
        System.out.println(new Example("Example String").getMessage());
        throw new Exception("This exception should log the line number");
    private String _message;

<project name="CompileErrorDemo" default="run" basedir=".">
    Demonstrate the lack of debug information in a case where it
    should be present.
  <!-- properties that should not be changed -->
  <property name="src"        location="src"/>
  <property name="build"      location="build"/>
  <target name="init">
    <mkdir dir="${build}"/>
  <target name="build" depends="init" description="compile the source ">
    <javac debug="true" debuglevel="lines, source" srcdir="${src}" destdir="${build}" >
        <pathelement path="${src}" />
  <target name="run" depends="build"
       description="run the compiled code">
    <java classname="Example" fork="true">
        <pathelement path="${build}"/>
  <target name="clean" description="clean out the output directories" >
    <delete dir="${build}"/>

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message