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

javac is not accepting correct code

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 22
    • 22
    • tools
    • None
    • b27

      This code is failing to compile:

      import java.util.*;
      import java.util.function.*;

      class Test {
          public interface X {
              Object O = new Object() {
                  Function<String, String> x(Map<String, String> m) {
                      // Error: local variables referenced from a lambda expression must be final or effectively final
                      return s -> m.get(s);
                  }
              };
          }
      }

      reported by Paul Sandoz

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

              Created:
              Updated:
              Resolved: