Silent removal of zero-valued entries from the line-number table
When using ASM to inspect or transform line tables it will silently ignore/strip zero-valued lines.
Zero-valued line entries should be treated as any other line value and a call to MethodVisitor.visitLineNumber should be made. (The JVM spec does not appear to have any other requirement than that the line entries are unsigned 2-byte values IFAICT. That is also consistent with JVM execution as illustrated by the attached code).
MethodVisitor never receives a callback.
Steps to Reproduce
Attached is a .class file with a method that has respectively a non-zero line followed by a zero-valued line. Any use of MethodVisitor on these lines will fail to act on the zero-valued entry. The result is that the throw will inherent the previous line value.
Second line number table is that of the main method:
$ javap -v -cp /tmp/test.zip com.android.tools.r8.debuginfo.AsmZeroLineEntryRegressionTest\$TestClass |grep line -B 1 LineNumberTable: line 126: 0 -- LineNumberTable: line 1: 0 line 0: 8
Executing the program will throw on "line 0":
$ java -cp /tmp/test.zip com.android.tools.r8.debuginfo.AsmZeroLineEntryRegressionTest\$TestClass Hello, world! Exception in thread "main" java.lang.RuntimeException: BOO! at com.android.tools.r8.debuginfo.AsmZeroLineEntryRegressionTest$TestClass.main(AsmZeroLineEntryRegressionTest.java:0)
Doing an "identity" transformation on this will strip the zero-valued line and the result will be a stack trace at line
More details can be found in the R8 regression test or via the R8 tracking bug.
Archive with the single class file test.zip