FIX: Function Call Is Not Executed When Used as Expression in Empty IF Block

ID: Q214531


The information in this article applies to:
  • Microsoft virtual machine


SYMPTOMS

The expression in the IF statement of an empty IF block is not executed.


CAUSE

This is a bug in the Just In Time (JIT) compiler where the empty IF block is optimized out. As a result, it does not execute the expression in the IF statement.


RESOLUTION

Try one of the following to work around this problem:

  • Upgrade the Microsoft virtual machine (Microsoft VM) to version 3154 or later. For additional information, please see the following article in the Microsoft Knowledge Base:
    Q163637 INFO: Availability of Current Build of Microsoft VM
  • Turn off the JIT. This can cause some Java programs to run at a slower speed. For additional information about the JIT, please see the following article in the Microsoft Knowledge Base:
    Q154580 Description of the Just-In-Time Compiler
  • Place code in the IF block that you want to execute. However, this might not be the effect you are looking for.


STATUS

This bug has been fixed in Microsoft virtual machine version 3154 or higher.


MORE INFORMATION

Steps to Reproduce Behavior

The following code reproduces the JIT bug when you run it on a computer containing an earlier version of the Microsoft virtual machine (such as 2924 or 2925):

public class ifop
{
   private static boolean runme()
   {
      System.out.println("runme got executed!");
      return(true);
   }

   public static void main(String[] args)
   {
      System.out.println("before call to runme");

      if (runme())
      {
         // do nothing
      }

      System.out.println("after call to runme");
   }
} 

When you run this sample code on the Microsoft virtual machine versions 2924 or 2925 you get the following output:

C:\>jview ifop
before call to runme
after call to runme


Upgrading the Microsoft virtual machine version 3154 (or later), turning the JIT off, or replacing the comment "// do nothing" with an executable statement produces the correct results as follows:

C:\>jview ifop
before call to runme
runme got executed!
after call to runme


REFERENCES

For additional information about Microsoft virtual machine, please see the following article in the Microsoft Knowledge Base:

Q163638 HOWTO: Automatically Update the Microsoft VM
For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, please see the following pages on the Microsoft Technical Support site:
http://support.microsoft.com/support/visualj/

http://support.microsoft.com/support/java/

Additional query words:

Keywords : kbJavaVM kbJIT kbGrpJava
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbbug


Last Reviewed: November 16, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.