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

There is no record for condition in ternary operator in LineNumberTable.

    XMLWordPrintable

    Details

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

      Description

      To reproduce run following code
      Expected to see record in line number table for "field % 2 == 0 ?"


      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 ? //Breakpoint
                      "true" + field :
                      "false" + field;
              return s;
          }
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jlahoda Jan Lahoda
              Reporter:
              anazarov Andrey Nazarov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: