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

The compiler removes "/ by zero" from ArithmeticException

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      generic

      Description

      The example below changes its behaviour during optimization.
      From some iteration it starts to print null instead '/ by zero'.

      See example below:
      (check with java -server Main and java -Xint)
      class Main {
          private void testDivisionByZero() {
              try {
                  int i = 0;
                  @SuppressWarnings("unused")
                  int j = 17 / i;
              } catch (ArithmeticException e) {
                  System.err.println(e.getMessage());
                  return;
              }
              throw new Error("Failure in testDivisionByZero");
          }

      public static void main(String[] args) {
      Main main = new Main();
      while(true) {
      main.testDivisionByZero();
      }
      }
          
      }

        Attachments

          Activity

            People

            Assignee:
            iveresov Igor Veresov
            Reporter:
            lmesnik Leonid Mesnik
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: