JDK-8236005 : local records shouldn't capture any non-static state from any enclosing type
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-12-16
  • Updated: 2020-01-29
  • Resolved: 2020-01-14
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 14 JDK 15
14 b32Fixed 15Fixed
Related Reports
Blocks :  
CSR :  
Description
test cases, provided by Tagir:

class X {
  public static void main(String[] args) {
    int x = 2;
    record Y() {
      void test() {
        System.out.println(x);
      }
    }
    new Y().test();
  }
}

class X {
  public static void main(String[] args) {
    int x = 2;
    record Y() {
      static final int y = x;
    }
    new Y();
  }
}
Comments
URL: https://hg.openjdk.java.net/jdk/jdk14/rev/2939d1a460ed User: vromero Date: 2020-01-14 12:08:15 +0000
14-01-2020