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

definite unassignment versus assertions

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.4.0
    • Fix Version/s: 5.0
    • Component/s: specification
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      1.5
    • CPU:
      generic
    • OS:
      solaris_8
    • Verification:
      Verified

      Description

      The specification for assertions is missing any description of their interaction
      with the try statement. Here is a test case, from the jacks suite, that
      illustrates the underlying question:

      public class T {
          public static void main(final String[] args) {
              final int i;
              try {
                  assert false : i=3;
              } finally {
                  i = 5;
              }
          }
      }

      Is this code legal, or is there an assignment to a possibly assigned
      final variable in the finally clause? I believe there is an error here.
      The suggested JLS wording is to augment the phrase (twice) in 16.2.14
      that reads

      ... V is definitely unassigned after the try block and V is definitely
      unassigned before every return statement that belongs to the try
      block, every throw statement that belongs to the tryblock, every
      break statement that belongs to the try block and whose break target
      contains (or is) the try statement, and every continue statement that
      belongs to the try block and whose continue target contains the try
      statement

      to include

      "and V is definitely unassigned after the last expression in every assert statement that belongs to the try block"

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: