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

inability of detection of definite assignment after a simple

XMLWordPrintable

    • sparc
    • generic



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

      a variable is not considered as definitely assigned after a
                   simple boolean assignment expression when true though it is
                   definitely assigned after its right-hand side when false. 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 false iff either a
                     is V or V is definitely assigned after the right-hand operand
                     expression when false.

                   (Java Language Specification, section 16.1.13)

      Test: compilation of the following test

      public class test
      {
      public static void main(String argv[])
      {
      int i = 777, j;
      boolean b = true;

      if (b = i < 0 || (j = -1) > 0);
      else
      System.out.println(j);
      }
      }

      produces such diagnostics:

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