Microsoft KB Archive/162966

From BetaArchive Wiki

Article ID: 162966

Article Last Modified on 5/12/2007



APPLIES TO

  • Microsoft Visual J++ 1.0 Standard Edition



This article was previously published under Q162966

SYMPTOMS

Calling an Automation method that returns a Boolean value is interpreted incorrectly from Java. If the COM object returns True, Java interprets the return value as False, or if it returns False, then Java interprets the return value as True.

RESOLUTION

The problem has been fixed with the latest Microsoft virtual machine (Microsoft VM). Please follow the link to http://www.microsoft.com/mscorp/java to download the latest Microsoft VM.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem has been fixed in Visual J++ 1.1.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a default MFC Automation Server.
  2. Using the Class Wizard (OLE Automation Tab) create an automation method that returns a BOOL.
  3. Build the project and run it once to register the server.
  4. From the command line run JAVATLB /U:T Server.TLB, where Server is your MFC Automation Server. The JAVATLB creates Java class files with information about the COM interfaces and methods. After you have created Java descriptions of COM components, the output window shows two useful types of information, the import statement and the Summary.txt notice. You have to use the command line because Java Type Library Wizard doesn't list MFC Server's Type Library.
  5. Create a new Java project.
  6. Create a Java class that uses the services from the MFC Automation Server. The following class illustrates how it uses the Automation Method that returns a BOOL:

    import server.*    // where server is the MFC Automation Server
    class javabool
    {
      public static void main(String args[])
      {
        System.out.println("\nStarting test...\n");
        IBoolTest btest = (IBoolTest) new BOOLTEST();
        btest.TestBool();                      //calling the Automation
                                                 Method
        System.out.println(btest.TestBool());
      }
    }
                            
  7. Save this .JAVA file and build it.
  8. When you run this Java Application, you will notice that Java interprets the Bool value incorrectly.


REFERENCES

For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, see the following pages on the Microsoft Technical Support site:


Additional query words: Java VM Bool COM

Keywords: kbbug kbfix kbvj110fix KB162966