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

inability of detection of definite assignment after a compound

XMLWordPrintable

    • sparc
    • generic



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

      a variable is not considered as definitely assigned after a
                   compound boolean assignment expression when true though it is
                   definitely assigned after its right-hand side when true. This
                   contradicts the following assertion:

                   Suppose that an assignment expression a = b, a &= b, a |= b, or
                   a ^= b is boolean-valued.

                   - V is definitely assigned after a &= b when true iff either a
                     is V or V would be definitely assigned after a & b (in the same
                     context) when true.

                   (Java Language Specification, section 16.1.13)

      Test: compilation of the following test

      public class test
      {
      public static void main(String argv[])
      {
      int i;
      boolean [] a = new boolean [10];

      a[0] = a[1] = true;
      if (a[1] &= a[0] && (i = -1) < 0)
      System.out.println(i);
      }
      }

      produces such diagnostics:

      novo40% javac test.java
      test.java:10: Variable i may not have been initialized.
      System.out.println(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: