JDK-6280731 : Hotspot problem with loop-variables of type long on jdk1.4.2/Itanium
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 1.4.2_08
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: itanium
  • Submitted: 2005-06-06
  • Updated: 2010-08-06
  • Resolved: 2005-09-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2_10 b02Fixed
Related Reports
Relates :  
Relates :  
Description
It seems that the hotspot-compiler has problems with loop variables of type long on the Itanium plattform for jdk 1.4.2.

Consider the following short test program:

---------------------------------------------------------------------------
public class TestLongLoop
{
    public static Integer getInteger()
    {
        long index;
        for(index = 10 ; index < Long.MAX_VALUE ; index++)
        {
          if (index > 2000) return new Integer((int)index); // (1)
        }

        System.out.println("INDEX is " + index);
        return null;
    }

    public static void main(String[] args)
        throws Exception
    {
        for(int i = 0 ; i < 1000 ; ++i)                      //  (2)
        {
            Integer x = getInteger();
            if(x==null)
            {
                System.out.println("GOT null after " + i + " iterations!");
                System.exit(20);
            }
        }
    }
}
---------------------------------------------------------------------------

On Linux/x86 and on Solaris, the program just terminates without any output.
On Linux/Itanium (and on Windows/Itanium) with jdk 1.4.2 (see below for the exact version) the program always terminates with the following output:

$ uname -a
Linux jtg-it4 2.4.21-4.EL #1 SMP Fri Oct 3 17:29:39 EDT 2003 ia64 ia64 ia64 GNU/Linux
$ java -showversion -Xmixed TestLongLoop
java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.4.2_08-b03, mixed mode)

INDEX is 11
GOT null after 182 iterations!

This means that the for-loop in the method getInteger() has been terminated with 'index' beeing 11 although it should run until 'index' has the value Long.MAX_VALUE.
Note that the number of iterations until termination may vary, while the index at which the for-loop in getInteger() terminates is always 11.

If the constant in the line marked '(1)' is increased, the number of iterations after which the loop will be incorrectly terminated, decreases.

This error does not happen if the program will be executed with '-Xint'. It also seems to be fixed in 1.5. At least I couldn't reproduce it with 1.5.0-beta2-b51a.

###@###.### 2005-06-06 09:03:59 GMT

Comments
EVALUATION Appears to be a duplicate of 4899484. The fix is fairly small and easy to backport. Re-assigning to sustaining for consideration in a 1.4.2 update. ###@###.### 2005-06-07 17:33:38 GMT
06-06-2005