FIX: COM Object Returns Incorrect Value for Bool

Last reviewed: January 29, 1998
Article 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 for Java. Please follow the link to http://www.microsoft.com/java to download the latest Microsoft Virtual Machine for Java. This version of the VM for Java requires Internet Explorer 3.01.

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 page 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 : JCOM
Technology : kbInetDev
Version : 1.0
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 29, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.