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

16.2.5: Clarify DU/DA for labeled statement with intervening finally block

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.8.0_05"
      Jaova(TM) SE Runtime Environment (build 1.8.0_05-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.3.9600]

      A DESCRIPTION OF THE PROBLEM :
      (Reported in the Java SE 4 timeframe) The definite assignment rules for control transfers don't take into account intervening finally clauses (even though javac does). Appropriate rules are needed to justify javac's behavior on this program.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      compile the enclosed program and observe that it is accepted despite the language specification requiring that it be rejected.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      language specification allows this program and defines its semantics
      ACTUAL -
      language specification does not allow this program

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class DA {
          public static void main(String[] args) {
              int a; // blank final
              label:
              try {
                  break label;
              } finally {
                  a = 12;
              }
              // according to JLS 16.2.5, "a" not assigned here (after labeled statement).
              // But javac accepts this:
              int b = a;
          }
      }

      ---------- END SOURCE ----------

            abuckley Alex Buckley
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: