FIX: Function call is not executed when used as expression in empty IF block (214531)



The information in this article applies to:

  • Microsoft virtual machine

This article was previously published under Q214531

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 more information about obtaining the latest version of the Microsoft VM, click the following article number to view the article in the Microsoft Knowledge Base:

    163637 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:

    154580 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:
jview if before call to runme after call to run

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:
jview if before call to runme runme got executed! after call to run

REFERENCES

For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:6/14/2006
Keywords:kbbug kbfix kbJIT KB214531 kbAudDeveloper