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

javac is not accepting correct code

    XMLWordPrintable

Details

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

    Description

      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

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: