ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Wolfe" <greg.wo...@MyPoints.com>
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.

Thanks,
-Greg Wolfe

----
running from ant:

$ ant
Buildfile: build.xml
 
init:
    [mkdir] Created dir: /home/gwolfe/msrc/emp/sample/build
 
build:
    [javac] Compiling 1 source file to /home/gwolfe/msrc/emp/sample/build
 
run:
     [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
 
BUILD SUCCESSFUL
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(Example.java:15)

==> note that debug information is available


---
src/Example.java:
/**
 * 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;
}
                                                                                

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





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