Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8193449

Fix for JDK-8192885 resulted in extra entry in LineNumberTable

XMLWordPrintable

    • b35
    • 10
    • generic
    • generic

      FULL PRODUCT VERSION :
      java version "10-ea"
      Java(TM) SE Runtime Environment (build 10-ea+35)
      Java HotSpot(TM) 64-Bit Server VM (build 10-ea+35, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      JDK-8192885 is marked as resolved in b35, I did a test and think that fix is incomplete / incorrect: compiler in JDK 10-ea+35 produces multiple entries in LineNumberTable for a last line of a foreach loop. Due to this in case if body of loop is not executed, debugger will misleadingly show that a step after loop - is the last line of the loop body.

      Background information: I'm one of developers of the JaCoCo code coverage tool. This tool relies on line number debug information within class files to provide code coverage highlighting. We have a regression test suite which uncovered the defect reported here.

      And due to this issue in the same case code coverage tool such as JaCoCo will highlight misleadingly last line of a body of foreach loop as partially executed.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the same source file as in JDK-8192885, which is also provided here.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Single entry for line 4 (without "line 4: 32") in LineNumberTable as this is the case with JDK 1.8.0_152-b16 , 9.0.1+11 and 10-ea+30.
      ACTUAL -
            LineNumberTable:
              line 3: 0
              line 4: 25
              line 5: 29
              line 4: 32
              line 6: 34


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class Example {
        static void example() {
          for (Object o : java.util.Collections.emptyList()) {
            nop(o);
          }
        }

        static void nop(Object o) {
        }
      }

      ---------- END SOURCE ----------

            vromero Vicente Arturo Romero Zaldivar
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: