Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8236005

local records shouldn't capture any non-static state from any enclosing type

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 14
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b32

      Backports

        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();
          }
        }

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved: