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

16: DU/DA analysis should be more conservative in loops

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 1.4.0
    • specification
    • Fix Understood

      The following spec bug is submitted in further support of the changes
      described in the evaluation of 4661694.

      The following program is required to be accepted under the current
      rules for definite unassignment. Yet this program repeatedly assigns
      to a final variable.

      class T {
          static class E extends Exception {}
          static void thr() throws E {
      throw new E();
          }
          public static void main(String[] args) {
      int count = 0;
      final int i;
      while (true) {
      try {
      i = count++;
      System.out.println("assigned " + i);
      thr();
      return;
      } catch (E e) {}
      }
          }
      }

      Here's another problem with DU analysis for break:

      class U {
          public static void main(String[] args) {
      final int i;
      for (int n=0; n<10; n++) {
      b: {
      try {
      if (true) break b;
      } finally {
      i = n;
      System.out.println("i = " + i);
      }
      return;
      }
      }
          }
      }

            abuckley Alex Buckley
            gafter Neal Gafter (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: