JDK-8226955 : Release Note: Bad EnclosingMethod Attribute on Classes Declared in Lambdas
  • Type: Sub-task
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 13
  • Priority: P3
  • Status: Closed
  • Resolution: Delivered
  • Submitted: 2019-06-28
  • Updated: 2021-12-02
  • Resolved: 2019-06-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 13
13Resolved
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.