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

don't allow a local class in a switch to capture a variable form the switch

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 1.4.0
    • Fix Version/s: None
    • Component/s: tools
    • Subcomponent:
    • CPU:
      generic
    • OS:
      solaris_8

      Description

      javac fails the jacks test 16.2.3-switch-1. The offending code is something
      like

              void f(int n) {
                  switch (n) {
                    case 12:
                      final int x;
                      x = 1;
                      class Local {
                          int y = x;
                      }
                      break;
                    case 13:
                      int z = new Local().y; // verify error in generated code
                  }
              }

      The problem is that the JLS allows this code, but the variable x hasn't
      been assigned at the point where it is captured.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gafter Neal Gafter
                Reporter:
                gafter Neal Gafter
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: