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

Exception at runtime due to lambda analyzer reattributes live AST

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 11
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b02
    • CPU:
      generic
    • OS:
      generic

      Description

      Below code throws exception when run with -XDfind=lambda at compile time.
      public class AnalyzerNotCopyingTest {
          public static void main(String... args) {
              new AnalyzerNotCopyingTest().run();
          }
          private void run() {
              Base b = new Base() {
                  public void run() {
                      test(this);
                  }
              };
              b.run();
          }
          private static void test(AnalyzerNotCopyingTest t) {
              throw new AssertionError("Should not be invoked!");
          }
          private static void test(Base b) {
                  //ok to invoke
          }
          public static interface Base {
              public abstract void run();
          }
      }

      javac -XDfind=lambda AnalyzerNotCopyingTest.java
      java AnalyzerNotCopyingTest

      Exception in thread "main" java.lang.NoSuchFieldError: this
              at AnalyzerNotCopyingTest$1.run(AnalyzerNotCopyingTest.java:16)
              at AnalyzerNotCopyingTest.run(AnalyzerNotCopyingTest.java:19)
              at AnalyzerNotCopyingTest.main(AnalyzerNotCopyingTest.java:10)

      This happens mainly because the lambda analyzer reattributes the live AST for "test(this)" .

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sdama Srinivas Dama
                Reporter:
                sdama Srinivas Dama
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: