Question

When I compile my project with Ant, the getFileName method of the MethodCall class of javassist returns null, but when I compile it with javac file by file it returns the file where the method is called. Why is this happening?

Here is my build.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project name="Tracer" default="jar" basedir=".">
    <target name="init" description="Creates the directory where the compiled classes will be stored">
        <mkdir dir="classes" />
    </target>
    <target name="compile" description="Compiles the classes" depends="init">
        <javac srcdir="src" destdir="classes" includeantruntime="false">
            <classpath>
                <fileset dir="lib">
                    <include name="**/*.jar" />
                </fileset>
            </classpath>
        </javac>
    </target>
    <target name="jar" depends="compile" description="Creates the project jar">
        <jar destfile="tracer.jar" basedir="classes">
            <fileset dir="src" includes="**/*.java" />
            <zipgroupfileset dir="lib" includes="**/*.jar" />
        </jar>
    </target>
    <target name="clean" description="Deletes the compiled classes">
        <delete dir="classes" />
        <delete file="tracer.jar" />
    </target>
    <target name="test" description="Target for building in Travis-CI" depends="compile" />
</project>
Was it helpful?

Solution

Found the problem!

In order for javassist to get the file name and line numbers it needs to have debug info enabled, and ant does not have it on by default.

So, the solution is to enable debug info in ant.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top