killme2008 / killme2008/aviatorscript
运行时发生异常的源码关联问题,即class中的LineNumberTable错乱的问题
- Dominant language
- Java
- Stars
- 5.2k
- Forks
- 906
- PR merge metrics
- No merged PRs in 30d
Description
使用脚本的时候 比如第三行发生了1/0的运行时异常 但是异常信息中显示的Aviatorscript_时间戳的那个生成的类的显示的错误行数目前是错误的,经过跟踪class的LineNumberTable发现 key是源码行号没问题 但是value的label 即currentLabel是错误的 ,然后目前的修改办法是
private void visitLineNumber(final Token token) {
if (token != null && token.getLineNo() > 0) {
this.mv.visitLineNumber(token.getLineNo(), this.currentLabel);
}
}
改成了
private void visitLineNumber(final Token token) {
if (token != null && token.getLineNo() > 0) {
// this.mv.visitLineNumber(token.getLineNo(), this.currentLabel);
// 确保每个指令都有正确的行号映射
Label lineLabel = new Label();
this.mv.visitLabel(lineLabel);
this.mv.visitLineNumber(token.getLineNo(), lineLabel);
this.currentLabel = lineLabel;
}
} ,试了是好用的 源代码行号正确了,作者大神看看有没有啥问题,看看要不要采纳下 @killme2008
Contributor guide
No contributing guide indexed for this repository
Research direction
Locate the compiler code containing visitLineNumber and inspect how currentLabel is assigned before bytecode instructions are emitted. Reproduce the issue with a script whose third line evaluates 1/0, then inspect the generated class's LineNumberTable and exception line. Done means runtime errors report the correct source line without breaking other generated bytecode.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100