Knowledge Base

FIX: JIT Gives Bad Results When Doing A Comparison Operation

Article ID: 191930

Article Last Modified on 10/23/2007


APPLIES TO


This article was previously published under Q191930

SYMPTOMS

The JIT compiler in Internet Explorer 3.02 (build 1518 of the Virtual Machine for Java) caused a problem where de-referencing an object and using it in a comparison operation in the same statement was causing incorrect results.

RESOLUTION

This problem has been fixed in later builds of the Virtual Machine for Java, or, alternatively, the JIT compiler may be turned off to avoid the bug.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been corrected in build 2252 and later of the Java VM (SDK for Java version 2.0 or higher and Internet Explorer 4.0 or higher.)

MORE INFORMATION

The included Java language source file demonstrates the problem. When you run the applet under build 1518 of the Virtual Machine for Java (Internet Explorer 3.02) with the JIT compiler enabled a result of "true" is returned for the test:
   if (1.0 > 2.0)
				

Steps to Reproduce Behavior

   import java.applet.*;
   import java.awt.*;
   import java.util.*;

   // badComp
   // 
   // Run under build 1518 of VM to see repro of bug
   // 
   public class badComp extends Applet
   {
      Vector    v1      = new Vector( );

      public void init()
      {
         v1.addElement( new Holder( 1.0, 2.0 ) );
      }

      public void paint(Graphics g)
      {
         g.drawString("" + which(0).lv + " > " +  which(0).hv + " = " +
              ( which(0).lv > which(0).hv), 10, 10) ;
      }

      Holder which( int i )
      {
         return ( Holder ) v1.elementAt( i );
      }
   }

   class Holder
   {
      double lv, hv;

      public Holder(double l, double h)
      {
         this.lv = l;
         this.hv = h;
      }
   }
				

Keywords: kbbug kbfix kbjit KB191930