Apparent JITC bug

Dan Hicks danhicks at fastmail.fm
Tue Aug 9 04:24:10 PDT 2011


This sequence fails on Linux JDK 1.6.0_21, and an unknown Java version 
on OS X 10.6.8:

|public  class  Prototype  {
   public  static  void  main(String[]  args)  {
     final  int  start=  Integer.MAX_VALUE/2;
     final  int  end=  Integer.MAX_VALUE;
     {
       long  b=  0;
       for  (int  i=  start;  i<  end;  i++)  {
         b++;
       }
       System.out.println(b);
     }
     {
       long  b=  0;
       for  (int  i=  start;  i<  end;  i++)  {
         b++;
       }
       System.out.println(b);
     }
   }
}
|

The second loop terminates early, producing a different, random, 
erroneous result when compared to the first.

http://stackoverflow.com/questions/6995225/erroneous-for-loops-in-java

I'm guessing the bug has something to do with trying to jump into a 
just-JITed loop while executing.

-- 
Dan Hicks
It is an ironic habit of human beings to run faster when we have lost our way.  --Rollo May

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-dev/attachments/20110809/4c951464/attachment.html 


More information about the hotspot-dev mailing list