Early Binding (VTable) vs Late Binding (IDispatch) |
|
By default, J-Integra calls COM methods using early binding (i.e. calling methods via vtable pointers). This is the case for both DCOM mode and native mode. In DCOM mode, J-Integra makes vtable and IDispatch:Invoke calls by talking the DCOM wire protocol (using pure Java) over TCP/IP. In native mode, J-Integra makes vtable and IDispatch:Invoke calls by using native code located in DLLs on Windows machines. There are only two situations where J-Integra uses late binding instead (i.e. calling methods via IDispatch:Invoke).
1. When a dispinterface is being accessed (a DISPINTERFACE is an interface that is not dual).
A dispinterface contains a set of properties and methods on which you can call IDispatch::Invoke, whereas a dual interface exposes properties and methods through IDispatch and directly through the VTable. From the IDL file of a COM component, you can find out whether an interface is defined as dispinterface or dual. Because J-Integra makes COM methods called via vtable invocation by default, you must select the Only generate IDispatch option of com2java tool to access a dispinterface from Java. Otherwise you may get this error:
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred
2. When the Only generate IDispatch option is selected before generating proxies for the COM object using the com2java tool, J-Integra uses IDispatch:Invoke to access both dispinterface and dual interfaces. For example, if a COM event is a dispinterface, then you must select the Only generate IDispatch option. Otherwise you may get AutomationException: 0x80040202 from the Java client.