-
CSR
-
Resolution: Approved
-
P3
-
minimal
-
Summary
Local records shouldn't capture any non-static state from theirs enclosing type. Both the spec and the implementation should be updated to enforce this.
Problem
Local records should not be allowed to capture any non-static state from any enclosing type
Solution
Fix the mentioned issue in the spec and the implementation
Specification
The following extra condition has been added to the definition of a local record [14.3]:
It is a compile-time error if a local record contains a usage of a variable declared in the enclosing block.
Following comments, the definition of a local record now reads as follows (The final sentence is new):
A local record is a record type declaration (8.10) that is not a member of a class. A local record is implicitly static. A local record is not a local class.
Example 14.3-1 has been clarified that it deals with local classes only.
- csr of
-
JDK-8236005 local records shouldn't capture any non-static state from any enclosing type
- Resolved