Skip to content

运行时发生异常的源码关联问题,即class中的LineNumberTable错乱的问题 #698

Description

@neitheraaa

使用脚本的时候 比如第三行发生了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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions