Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8215470 Bad EnclosingMethod attribute on classes declared in lambdas
  3. JDK-8226955

Release Note: Bad EnclosingMethod Attribute on Classes Declared in Lambdas

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: P3
    • Resolution: Delivered
    • Affects Version/s: 13
    • Fix Version/s: 13
    • Component/s: tools
    • Subcomponent:
    • Verification:
      Verified

      Description

      If an anonymous or local inner class is declared inside of a lambda, the `EnclosingMethod` attribute on that class refers to the synthetic lambda method rather than to the method that enclosed the original declaration. The original method should be considered as the closest lexically enclosing method.

      The proposed solution to this issue is to point the `EnclosingMethod` attribute of inner classes declared inside a lambda to the original enclosing method. The Java compiler was updated, so that the `EnclosingMethod` attribute of anonymous or local inner classes declared inside a lambda point to the method enclosing the declaration.

      The following is the related section in the Java Language Specification:
      JVMS 11 4.7.7: It is the responsibility of a Java compiler to ensure that the method identified via the method_index is indeed the closest lexically enclosing method of the class that contains this `EnclosingMethod` attribute.

        Attachments

          Activity

            People

            Assignee:
            vromero Vicente Arturo Romero Zaldivar
            Reporter:
            vromero Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: