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

Bogus duplicate assignment errors for blank class finals in unreachable code

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.2.0
    • 1.1.3
    • tools
    • None
    • 1.2beta
    • sparc
    • solaris_2.5.1
    • Not verified

      class B {
          static final int x;
          static { while (true) {} }
          static { x = 1; }
      }

      ==>

      Init4.java:4: Statement not reached.
          static { x = 1; }
                 ^
      Init4.java:4: Can't assign a second value to a blank final variable: x
          static { x = 1; }
                   ^

      ---

      The second error message is incorrect. Clearly, 'x' has not been previously
      assigned, and any reasonable definition of "definite unassignment"
      (unfortunately not formally defined in the JLS or the current inner class
      specification) would recognize this.

      The first error message should not have been issued according to the JLS, but
      the statment is in fact unreachable and will be detected as such in the course
      of the definite assignment/unassingment analysis whether the error message is
      issued or not. A separate bug report has been filed for this, 4063938.



            wmaddoxsunw William Maddox (Inactive)
            wmaddoxsunw William Maddox (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: