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

15.27.4: Clarify the identity of the result of evaluating a lambda expression

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 11
    • 10
    • specification

      The JSR-335 spec contained the following normative text: (see http://cr.openjdk.java.net/~dlsmith/jsr335-pfd/spec/E.html#E15.27.4)

      -----
      To evaluate the lambda expression, either a new instance of an appropriate class is allocated and initialized, or an existing instance of an appropriate class is referenced.

      This implies that the behavior of an equality operator (15.21) is unpredictable when applied to the result of evaluation of a lambda expression: the equality test may produce different results in different implementations, or even upon different lambda expression evaluations in the same implementation.
      -----

      The second paragraph did not make JLS8 for various reasons, although informative text was included about the nature of the object resulting from lambda expression evaluation. Per JDK-8202922, it is desirable to clarify the identity of the object, also in informative text:

      -----
      This implies that the identity of the result of evaluating a lambda expression (or, of serializing and deserializing a lambda expression) is unpredictable, and therefore identity-sensitive operations (such as reference equality, object locking, and `System.identityHashCode()`) may produce different results in different implementations, or even upon different lambda expression evaluations in the same implementation.
      -----

            abuckley Alex Buckley
            abuckley Alex Buckley
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: