FIX: COM Object Returns Incorrect Value for Bool

ID: Q162966


The information in this article applies to:
  • Microsoft Visual J++, version 1.0


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

http://support.microsoft.com/support/visualj/

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

Additional query words: Java VM Bool COM

Keywords : kbVJ100bug kbVJ110fix JCOM
Version : 1.0
Platform : WINDOWS
Issue type : kbbug


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