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

javac treats integer division by (constant) zero as an error.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.2.0
    • 1.1.4
    • tools
    • None
    • 1.2beta4
    • x86
    • windows_95, windows_nt
    • Not verified

      The original description of this bug does not seem to match the synopsis. The following program does:

      public class zero {
          public static void main(String[] args) {
      System.out.println(1/0);
          }
      }

      Running the above yields:


      zero.java:3: Arithmetic exception.
              System.out.println(1/0);
                                  ^
      1 error

      -------
      Here is the original description for this bug, which more properly is described by bugid 4019304:

      class UofO {
          private float value = 10;
          private static final float one_sixth_inch = (float)((1/6)*0.0254);

          public float getm() { return value; }

          public float this_compiles() {
      float val = one_sixth_inch;
      return getm() / val;
          }
          public float this_doesnt_compile() {
      return (getm() / one_sixth_inch);
          }
      }

            tturnidgsunw Todd Turnidge (Inactive)
            tbell Tim Bell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: