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

There is no records in LineNumberTable attribute for ternary operator ?: splitted to several lines.

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 9
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b06
    • Verification:
      Verified

      Description

      To reproduce run following code
      Expected to see
      "true" + field : //Breakpoint
      "false" + field; //Breakpoint
      lines in LineNumberTable attribute

      import com.sun.tools.classfile.*;

      import java.io.IOException;
      import java.util.Arrays;

      public class Test {
          public static void main(String[] args) throws IOException, ConstantPoolException {
              ClassFile someTestIn = ClassFile.read(Test.class.getResourceAsStream("Test.class"));
              for (Method m : someTestIn.methods) {
                  if ("method".equals(m.getName(someTestIn.constant_pool))) {
                      Code_attribute code_attribute = (Code_attribute) m.attributes.get(Attribute.Code);
                      for (Attribute at : code_attribute.attributes) {
                          if (Attribute.LineNumberTable.equals(at.getName(someTestIn.constant_pool))) {
                              LineNumberTable_attribute att = (LineNumberTable_attribute) at;
                              Arrays.asList(att.line_number_table).forEach(e -> System.out.println("Line number = " + e.line_number));
                          }
                      }
                  }
              }
              method();
          }

          public static int field;

          public static String method() {
              String s = field % 2 == 0 ?
                      "true" + field : //Breakpoint
                      "false" + field; //Breakpoint
              return s;
          }
      }

        Attachments

          Activity

            People

            Assignee:
            pgovereau Paul Govereau (Inactive)
            Reporter:
            anazarov Andrey Nazarov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: