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

8.3.1.2: final fields must be DA (and moreover not DU) at end of ctor

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.8.0_05"
      Java(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 :
      The enclosed program is required by the language specification to be accepted, but javac rejects it. This is a bug in the specification that I last reported on 4/11/2011 along with a bunch of other problems that were ignored.

      ADDITIONAL REGRESSION INFORMATION:
      This bug in the language specification has been in every version of the spec.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the attached program. Although the spec requires it be accepted, it is rejected.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Spec 8.3.1.2 says "A blank final instance variable must be definitely assigned (§16.9) at the end of every constructor (§8.8) of the class in which it is declared; otherwise a compiletime error occurs."

      This is incomplete; the spec accepts the enclosed program, but javac (properly) rejects it.
      ACTUAL -
      Spec requires the program be accepted.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Main {
          final int x;
          public Main() {
              return;
              // x is definitely assigned here
          }
          public static void main(String[] args) {
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Ignore the buggy specification, and do not expect it to be fixed.

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

              Created:
              Updated:
              Resolved: