![]()
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Type Mappings Between Java and COMThe Microsoft virtual machine allows most constructs that can be specified in a type library to be accessed from Java. However, only OLE Automation-compatible types are supported fully. Most other types will require Custom Marshaling. COM constructs that cannot be described in a type library are inaccessible from Java. This limitation is in place mainly because the current type library model is not rich enough to describe all interfaces. To learn more about type libraries, see the OLE SDK. Element Types Defined in Type LibrariesThere are five basic types of elements that can be defined in Object Description Language (ODL), and thus in a type library. These elements are mapped to Java as follows:
The interface keyword in ODL is used to define custom (that is, vtable based) interfaces. The dispinterface keyword in ODL is used to define dispatch interfaces. Properties in the dispatch interface are accessible in Java through two methods named get<property> and put<property> in the Java interface. Interface MethodsThe methods generated for an interface do not include those it inherits from IUnknown or IDispatch. Methods declared with the propget or propput attributes are exposed with get or put prepended to their names. Types Supported as ParametersThe following table lists the ODL types that are supported and the Java type that each ODL type maps to:
For information on accessing the contents of a VARIANT structure, see the class Variant. IUnknown is the interface from which all COM interfaces are derived. The Java versions of COM interfaces are derived from com.ms.com.IUnknown. Because IUnknown is simply a placeholder for COM interfaces, you never have to call any methods on com.ms.com.IUnknown. If your Java program calls a COM method that takes a parameter of type com.ms.com.IUnknown, you can pass any COM interface. If your Java program calls a COM method that has com.ms.com.IUnknown as its return type, you can cast the return value to the COM interface you're expecting. Certain ODL attributes cause parameters to be treated in a special manner:
Sample DeclarationsFollowing are some ODL declarations and their corresponding Java declarations: Declarations with simple parameters:
Declarations with string parameters:
Declarations with VARIANT parameters:
Declarations with interface pointer parameters:
For more information on HRESULTs returned by COM functions, see Handling COM Errors in Java.
|
![]() |
© 1998 Microsoft Corporation. All rights reserved. Terms of use. |