Exception at runtime due to lambda analyzer reattributes live AST

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 11
    • Affects Version/s: None
    • Component/s: tools
    • b02
    • generic
    • generic

      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)" .

            Assignee:
            Srinivas Dama (Inactive)
            Reporter:
            Srinivas Dama (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: