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

jvm abort on integer remainder overflow on x86

XMLWordPrintable

    • sparc
    • solaris_2.4



      Name: swC45995 Date: 01/29/97

      jvm aborts when integer remainder operation results in overflow
      though JLS says:

      The remainder operation for operands that are integers after binary numeric
      promotion produces a result value such that (a / b) * b + (a % b) is equal
      to a. This identity holds even in the special case that the dividend is the
      negative integer of largest possible magnitude for its type and the divisor
      is -1 (the remainder is 0). (#15.16.3)

      Nevertheless execution of the following test

      import java.io.PrintStream;

      public class test
      {
      public static void main(String args[]) {
      int i = 0x80000000;

      if (i % - 1 != 0)
      System.out.println("fail");
      else
      System.out.println("pass");
      }
      }

      aborts instead of producing correct output which is:

      pass

      ======================================================================

            tlindholsunw Timothy Lindholm (Inactive)
            wensunw Wen Wen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: