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

Umbrella: Add support for lambda expressions

    Details

    • Subcomponent:
    • CPU:
      unknown
    • OS:
      generic

      Description

      Add support for lambda expression/method references to the Java compiler. The functionalities to be added are described in this public document:

      http://cr.openjdk.java.net/~briangoetz/lambda/lambda-state-3.html

      And, also, in the public JSR 335 EDR, available at the following URL:

      http://jcp.org/aboutJava/communityprocess/edr/jsr335/index.html

        Issue Links

        1.
        Add type-checking support for default methods Sub-task Closed Maurizio Cimadamore  
         
        2.
        Add parser support for default methods Sub-task Closed Maurizio Cimadamore  
         
        3.
        Add target-typing support in method context Sub-task Closed Maurizio Cimadamore  
         
        4.
        Add attribution support for method references Sub-task Closed Maurizio Cimadamore  
         
        5.
        Add attribution support for lambda expressions Sub-task Closed Maurizio Cimadamore  
         
        6.
        Simplify error reporting API in Check.CheckContext interface Sub-task Closed Maurizio Cimadamore  
         
        7.
        Integrate efectively final check with DA/DU analysis Sub-task Closed Maurizio Cimadamore  
         
        8.
        Inference cleanup: add helper class to handle inference variables Sub-task Closed Maurizio Cimadamore  
         
        9.
        Inference: cleanup usage of Type.ForAll Sub-task Closed Maurizio Cimadamore  
         
        10.
        Inference cleanup: remove bound check analysis from visitors in Types.java Sub-task Closed Maurizio Cimadamore  
         
        11.
        Separate DA/DU logic from exception checking logic in Flow.java Sub-task Closed Maurizio Cimadamore  
         
        12.
        Encapsulate check logic into Attr.ResultInfo Sub-task Closed Maurizio Cimadamore  
         
        13.
        Some diagnostic methods do not go through Log.report Sub-task Closed Maurizio Cimadamore  
         
        14.
        attribution code for diamond should not rely on mutable state Sub-task Closed Maurizio Cimadamore  
         
        15.
        Attr.checkMethod should be called after inference variables have been fixed Sub-task Closed Maurizio Cimadamore  
         
        16.
        Attr.java has an unsoundness in method arguments attribution Sub-task Closed Maurizio Cimadamore  
         
        17.
        Merge proto-kind and proto-type into a single result class Sub-task Closed Maurizio Cimadamore  
         
        18.
        Update 292 overload resolution logic to match JLS Sub-task Closed Maurizio Cimadamore  
         
        19.
        Resolve should support nested resolution contexts Sub-task Closed Maurizio Cimadamore  
         
        20.
        Merge the two method applicability routines Sub-task Closed Maurizio Cimadamore  
         
        21.
        Add parser support for method references Sub-task Closed Maurizio Cimadamore  
         
        22.
        Add parser support for lambda expressions Sub-task Closed Maurizio Cimadamore  
         
        23.
        Add AST node for method references Sub-task Closed Maurizio Cimadamore  
         
        24.
        Add AST node for lambda expressions Sub-task Closed Maurizio Cimadamore  
         
        25.
        Cleanup Resolve.findMethod Sub-task Closed Maurizio Cimadamore  
         
        26.
        New instance creation expression using diamond is checked twice Sub-task Closed Maurizio Cimadamore  
         
        27.
        Inference cleanup: remove redundant exception classes in Infer.java Sub-task Closed Maurizio Cimadamore  
         
        28.
        Add back-end support for invokedynamic Sub-task Closed Maurizio Cimadamore  
         
        29.
        Add generation of lambda implementation code: invokedynamic call, lambda method, adaptor methods Sub-task Closed Robert Field  
         
        30.
        Implement runtime lambda metafactory Sub-task Resolved Robert Field  
         
        31.
        Add javax.lang/com.source support for default methods Sub-task Resolved Maurizio Cimadamore  
         
        32.
        Add support for intersection types in cast expression Sub-task Closed Maurizio Cimadamore  
         
        33.
        Add lambda tests Sub-task Closed Maurizio Cimadamore  
         
        34.
        Bad compiler diagnostic generated when poly expression is passed to non-existent method Sub-task Closed Maurizio Cimadamore  
         
        35.
        Add support for generic functional descriptors Sub-task Closed Maurizio Cimadamore  
         
        36.
        Add checks for method reference well-formedness Sub-task Closed Maurizio Cimadamore  
         
        37.
        Expression statement lambdas should be void-compatible Sub-task Resolved Maurizio Cimadamore  
         
        38.
        Add support for private interface methods in interfaces Sub-task Resolved Maurizio Cimadamore  
         
        39.
        Add support for static interface methods Sub-task Closed Maurizio Cimadamore  
         
        40.
        Cleanup Resolve.AmbiguityError Sub-task Closed Maurizio Cimadamore  
         
        41.
        Restructure DeferredAttr to allow pluggable deferred type completers Sub-task Closed Maurizio Cimadamore  
         
        42.
        Restructure method check code to allow pluggable checkers Sub-task Closed Maurizio Cimadamore  
         
        43.
        Implement overload resolution as per latest spec EDR Sub-task Closed Maurizio Cimadamore  
         
        44.
        Remove support for synchronized interface methods Sub-task Closed Maurizio Cimadamore  
         
        45.
        Treatment of '_' as identifier Sub-task Closed Maurizio Cimadamore  
         
        46.
        Add support for 'package' as access modifier Sub-task Closed Maurizio Cimadamore  
         
        47.
        Add support for array constructor references Sub-task Closed Maurizio Cimadamore  
         
        48.
        Fix provisional applicability for method references Sub-task Closed Maurizio Cimadamore  
         
        49.
        Add graph inference support Sub-task Closed Maurizio Cimadamore  
         
        50.
        Refactor DeferredAttrContext so that it points to parent context Sub-task Closed Maurizio Cimadamore  
         

          Activity

          Hide
          mcimadamore Maurizio Cimadamore added a comment -
          This issue seems to be triggered a lot more frequently when lambda support is enabled
          Show
          mcimadamore Maurizio Cimadamore added a comment - This issue seems to be triggered a lot more frequently when lambda support is enabled
          Hide
          mcimadamore Maurizio Cimadamore added a comment -
          Lambda and method references are now in TL. We can close this tracking issue.
          Show
          mcimadamore Maurizio Cimadamore added a comment - Lambda and method references are now in TL. We can close this tracking issue.
          Hide
          vromero Vicente Arturo Romero Zaldivar added a comment -
          Tighter handling of raw types means more return types are erased.

          After the subtask "Attr.checkMethod should be called after inference variables have been fixed" in this umbrella project has been applied, programs like:

          ---------------------------------------------------------------------------------------------
          import java.util.List;

          class ReproOne {

              static class Baz<T> {
                  public static List<Baz<Object>> getElements(Baz<Object> transcoder) {
                      return null;
                  }
              }

              private static void bar(Baz arg) {
                  Baz element = Baz.getElements(arg).get(0);
              }
          }

          //based on a code provided by cushon@google.com at compiler-dev list
          -------------------------------------------------------------------------------------

          which is accepted with warnings by javac 7, are not accepted anymore by javac 8.

          The javac 8 output for this code is:

          ReproOne.java:12: error: incompatible types: Object cannot be converted to Baz
              Baz element = Baz.getElements(arg).get(0);
                                                    ^
          Note: ReproOne.java uses unchecked or unsafe operations.
          Note: Recompile with -Xlint:unchecked for details.
          1 error

          What is happening here is that a raw type is being passed to the getElements(Baz<Object>) method which is applicable by subtyping (see the JLS, Java SE 7 Edition, section 15.12.2.2), so an unchecked conversion is necessary for the method to be applicable, so it's return type is erased (see the JLS, Java SE 7 Edition, section 15.12.2.6), in this case the return type of getElements(Baz<Object>) will be java.util.List instead of java.util.List<Baz<Object>> and thus the return type of get(int) will be Object which is not assignment-compatible with Baz.

          The original discussion and more examples can be found at: http://mail.openjdk.java.net/pipermail/compiler-dev/2013-October/007726.html
          Show
          vromero Vicente Arturo Romero Zaldivar added a comment - Tighter handling of raw types means more return types are erased. After the subtask "Attr.checkMethod should be called after inference variables have been fixed" in this umbrella project has been applied, programs like: --------------------------------------------------------------------------------------------- import java.util.List; class ReproOne {     static class Baz<T> {         public static List<Baz<Object>> getElements(Baz<Object> transcoder) {             return null;         }     }     private static void bar(Baz arg) {         Baz element = Baz.getElements(arg).get(0);     } } //based on a code provided by cushon@google.com at compiler-dev list ------------------------------------------------------------------------------------- which is accepted with warnings by javac 7, are not accepted anymore by javac 8. The javac 8 output for this code is: ReproOne.java:12: error: incompatible types: Object cannot be converted to Baz     Baz element = Baz.getElements(arg).get(0);                                           ^ Note: ReproOne.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error What is happening here is that a raw type is being passed to the getElements(Baz<Object>) method which is applicable by subtyping (see the JLS, Java SE 7 Edition, section 15.12.2.2), so an unchecked conversion is necessary for the method to be applicable, so it's return type is erased (see the JLS, Java SE 7 Edition, section 15.12.2.6), in this case the return type of getElements(Baz<Object>) will be java.util.List instead of java.util.List<Baz<Object>> and thus the return type of get(int) will be Object which is not assignment-compatible with Baz. The original discussion and more examples can be found at: http://mail.openjdk.java.net/pipermail/compiler-dev/2013-October/007726.html

            People

            • Assignee:
              mcimadamore Maurizio Cimadamore
              Reporter:
              mcimadamore Maurizio Cimadamore
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: