JDK-6196102 : Integer seems to be greater than Integer.MAX_VALUE
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 1.4.2,5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS:
    generic,linux,windows_2000,windows_xp generic,linux,windows_2000,windows_xp
  • CPU: generic,x86,itanium
  • Submitted: 2004-11-16
  • Updated: 2010-04-02
  • Resolved: 2009-06-30
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

FULL OS VERSION :
Windows XP

A DESCRIPTION OF THE PROBLEM :
The following code normally wouldn't enter the if-condition with the System.out.println-statement. But after some loops (14668Loops on my PC)
it does !

It occures only with option -server . With -client everything seems to be ok.

THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No

THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
please run the source above.

EXPECTED VERSUS ACTUAL BEHAVIOR :
No output is expected. But the code produces output.
REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class HotSpotError {
    static public void main(String[] args) {
        int i1 = 0;
        int i2 = Integer.MAX_VALUE;

        while (i1 >= 0) {
            i1++;
            if (i1 > i2) {
                System.out.println("E R R O R: " + i1);
                return;
            }
        }
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
use VM-option  -client
###@###.### 2004-11-16 19:26:21 GMT

Comments
EVALUATION Yes. This is the Sign flip issue. We will fix this in CR 5091921.
30-06-2009

EVALUATION Problem is with canonicalization of loop exit test in preparation for loop transformation. do while (++i <= limit) becomes do while (++i < limit+1) This isn't correct when limit is maxInt. ###@###.### 2004-11-18 20:12:29 GMT ###@###.### 2004-11-18 20:37:04 GMT
18-11-2004