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

Blank final variables can be assigned twice in constructors.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.1.4
    • tools
    • generic
    • generic


      allan.jacobs@Eng 1997-10-27

      The rules for assigning initial values to blank final variables say
      that they can be assigned in constructors. Such variables can be
      assigned values at most once in every execution path. It is possible
      to get one constructor to call another and to have both assign a value
      to the same blank final variable.

      The following test code is derived from Modena (v 2.2) test
      niner117.java.

      algol% cat X.java
      class X {
        final int i;
        X() { i = 10; }
        X (int j) { X ox = new X(); i = j; }
        public static void main( String[] argv ) {
           X ox = new X(2);
           System.out.println(ox.i);
        }
      }
      algol% java -fullversion
      java full version "1.1.4n:1997.10.16"
      algol% javac -d . X.java
      algol% java X
      2

      allan.jacobs@Eng 1997-11-04

      The test is bad. Please close this bug.

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: