"来源不明"在Java堆栈跟踪,但行号在类文件 [英] "Unknown Source" in java stack trace, yet line numbers are in the class file
问题描述
我写的是抛出异常,因为它应该一个超级简单的Java类。然而,堆栈跟踪我得到这个样子的:
I've written a super simple java class that is throwing exceptions as it should. However the stack trace I'm getting looks like this:
java.lang.RuntimeException: hello
at Main.go(Unknown Source)
at Main.main(Unknown Source)
注意:有在堆栈跟踪中没有行号,我想那里是
都是关于在编译时添加正确的参数,以确保行号居然让它在类文件中找到google搜索这个问题时的答案。不过,我不相信这是我的问题,因为我有这个在我的蚂蚁的build.xml
The answers you find when googling this problem are all about adding the correct parameters at compile time to make sure the line numbers actually make it into the class file. However, I don't believe that's my problem as I have this in my ant build.xml
<javac
debug="true"
debuglevel="lines,vars,source"
includeAntRuntime="false"
classpathref="classpath.compile"
srcdir="${src.dir}"
destdir="${build.classes}" />
此外,根据javap的,它看起来像的行号并使其在
Also, according to javap, it looks like the line numbers did make it in:
$ javap -l ./build/classes/Main | head -n 9
public class Main extends java.lang.Object{
public Main();
LineNumberTable:
line 14: 0
line 22: 4
line 23: 15
line 24: 26
那么怎么办?是否有一个参数,我需要在JVM中设置当我运行code?
So what gives? Is there a param I need to set in the jvm when I run the code?
谢谢!
推荐答案
我认为正确的做法是:
<javac debug="true" debuglevel="lines,vars,source"
请注意有之间没有空格的线,增值经销商,源的
Note there are no spaces between lines,vars,source
这篇关于&QUOT;来源不明&QUOT;在Java堆栈跟踪,但行号在类文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!