-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
None
-
1.1.4
-
x86
-
windows_95
Name: laC46010 Date: 10/09/97
JDK1.1.4 with JIT v. 57 fails to pass the following JCK-114a test case:
lang/EXPR/expr275/expr27501/expr27501.html
because 0x80000000/-1 incorrectly throws "java.lang.ArithmeticException: / by zero"
It's particularly strange that the test is passed on WinNT.
JLS, [p. 352, 15.16.2 Division Operator / ] says:
> There is one special case that does not satisfy this rule: if the
> dividend is the negative integer of largest possible magnitude for its
> type, and the divisor is -1, then integer overflow occurs and the
> result is equal to the dividend. Despite the overflow, no exception is
> thrown in this case. On the other hand, if the value of the divisor in
> an integer division is 0, then an ArithmeticException is thrown.
An example below (which is modified version of the JCK test)
produces the following output:
--------------output----------------
before
catched: java.lang.ArithmeticException: / by zero - / by zero
failed 5
------------------------------------
--------------modified expr27501.java--------------------
//File: @(#)expr27501.java 1.1 96/10/06
//Copyright 10/06/96 Sun Microsystems, Inc. All Rights Reserved
//package javasoft.sqe.tests.lang.expr275.expr27501;
import java.io.PrintStream;
import java.lang.Exception;
public class expr27501
{
public static void main(String args[])
{
System.exit(run(args, System.out) + 95/*STATUS_TEMP*/);
}
public static int run(String args[], PrintStream out)
{
int i=5, j = 0x80000000, k = -1;
boolean was_exception = false;
try {
out.println("before");
i = j / k;
out.println("after");
} catch (Exception e) {
was_exception = true;
out.println("catched: " + e + " - " + e.getMessage());
}
if (was_exception) {
out.println("failed " + i);
return 2;
} else {
out.println("passed");
return 0;
}
}
}
---------------------------------------------------------
======================================================================