RFR: JDK14-8236005: local records shouldn't capture any non-static state from any enclosing type

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Sat Jan 11 01:02:24 UTC 2020


On 10/01/2020 22:53, Vicente Romero wrote:
> but this code is accepted:
>
> class R {
>      void m() {
>          int z = 0;
>          record RR(int x) { public int x() { return z; }};
>      }
> }

Why is this accepted? Isn't capture of locals also disabled, as 
demonstrated in the test:

// Cant capture locals
+ assertFail("compiler.err.non-static.cant.be.ref",
+ "class R { \n" +
                  "    void m(int y) { \n" +
                  "        record RR(int x) { public int x() { return y; }};\n" +
                  "    }\n" +
                  "}");

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20200111/fb3489bc/attachment.htm>


More information about the compiler-dev mailing list