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

IfNode::fold_compares() may lead to incorrect execution

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 11
    • 10, 11
    • hotspot
    • b11

      Test case:

      public class FoldedIfNonDomMidIf {
          public static void main(String[] args) {
              for (int i = 0; i < 20_000; i++) {
                  test_helper(0, 0);
                  test_helper(20, 0);
                  test(12);
              }
              if (test(14) != null) {
                  throw new RuntimeException("Incorrect code execution");
              }
          }

          private static Object test(int i) {
              return test_helper(i, 0x42);
          }

          static class A {

          }

          static final MyException myex = new MyException();

          private static Object test_helper(int i, int j) {
              Object res = null;
              try {
                  if (i < 10) {
                      throw myex;
                  }

                  if (i == 14) {

                  }

                  if (i > 15) {
                      throw myex;
                  }
              } catch (MyException e) {
                  if (j == 0x42) {
                      res = new A();
                  }
              }
              return res;
          }

          private static class MyException extends Exception {
          }
      }

            roland Roland Westrelin
            roland Roland Westrelin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: