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

16.2.5: Clarify DU/DA for labeled statements with break

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 1.4.0
    • specification
    • Fix Understood

      Considering the tentative decision on 4642762, I presume we should
      consider that
      in the following program the second break statement is not one that
      "may exit the labelled statement" (16.2.5), and that consequently the
      program should be accepted by a compiler. A similar issue arises in
      the context of 16.2.8 (switch).

      If that is our position (and I hope it is), then there are obvious
      errors in 16.2.9, 16.2.10 and 16.2.11 (the three loops) which use the
      language "V is [un]assigned before every break statement for which the
      [loop] statement is the break target." It would be strange to make
      accomodation for a finally that cannot complete normally in one
      context but not in another context.


      class Tnewflow {
          void f(int x) {
      final int i;
      L: {
      if (x==0) break L;
      try {
      i = 3;
      break L; // may exit L?
      } finally {
      return;
      }
      }
      i = 2; // definitely unassigned?
          }
      }

            abuckley Alex Buckley
            gafter Neal Gafter (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: