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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 14
    • None
    • tools
    • 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

          1. 8236005
            2 kB
            Vicente Arturo Romero Zaldivar

          Issue Links

            Activity

              People

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

                Dates

                  Created:
                  Updated:
                  Resolved: