当我使用Ant编译我的项目时,javassist的MethodCall类的getFileName方法返回null,但是当我用javac文件逐个文件编译它时,它返回调用该方法的文件。为什么会这样?
这是我的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>
答案 0 :(得分:0)
发现了问题!
为了让javassist获取文件名和行号,需要启用调试信息,默认情况下ant没有启用它。
因此,解决方案是在ant。中启用调试信息。