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

inability of detection of definite assignment before the right-

XMLWordPrintable

    • sparc
    • generic



      Name: ###@###.### Date: 09/05/96

      a variable is not considered as definitely assigned before
                   the right-hand side of an assignment expression though it is
                   definitely assigned after an index expression within the
                   left-hand side of the assignment. This contradicts the following
                   assertion:

                   Suppose that an assignment expression a = b, a += b, a -= b,
                   a *= b, a /= b, a %= b, a <<= b, a >>= b, a >>>= b, a &= b,
                   a |= b, or a ^= b is not boolean-valued.

                   - V is definitely assigned before b iff V is definitely assigned
                     after a.

                   (Java Language Specification, section 16.1.14)

      Test: compilation of the following test

      public class test
      {
      public static void main(String argv[])
      {
      int [] a = {1, 2, 3, 4, 5};
      int i, r;

      r = (a[i = 1] = 777 + i);
      System.out.println(r);
      }
      }

      produces such diagnostics:

      novo40% javac test.java
      test.java:8: Variable i may not have been initialized.
      r = (a[i = 1] = 777 + i);
      ^
      1 error

      ======================================================================

            fyellinsunw Frank Yellin (Inactive)
            wensunw Wen Wen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: