Problem with BSTR OUT parameter (.DLL)
Luc Gorissen <[email protected]> Fri, 10 Feb 2006 08:16:38 -0500
| Newsgroups | gmane.comp.windows.devel.jawin |
|---|---|
| Message-ID | <LISTSERV%[email protected]> |
What I've done
I want to use a .DLL from Java so I decided to use JaWIN.
I'm using release 'jawin-2.0-alpha1' and I generated the stubs
with jawinBrowser. I used the resulting stub code in my java project
and was able to call the .DLL. So far, so good.
However, I ran into errors when calling functions that return a string,
e.g. the function with the following
signature:
Function GetObjectRelationTypes
[out] BSTR BSTR List )
Result: [out, retval] BSTR
The Java code below throws the 'org.jawin.COMException: 80020005: Type
mismatch' exception:
IASCORSA iascorsa = new IASCORSA(ASCORSA.CLSID);
String[] list = new String[20];
boolean suc = iascorsa.GetObjectRelationTypes(list);
Of course the question is: what's wrong?
Below, the execution trace:
IASCORSA.GetObjectRelationTypes(String[] List): about to call InvokeN
IASCORSA.invokeN(String meth, Object[] args): about to call invokeN(meth,
args,
(args != null ? args.length : 0))
IASCORSA.invokeN(String meth, Object[] args, int argsExpected): entered
IASCORSA.invokeN(String meth, Object[] args, int argsExpected): meth <>
null
IASCORSA.invokeN(String meth, Object[] args, int argsExpected): INVOKE_INST
[args
Expected]: v:
IASCORSA.invokeN(String meth, Object[] args, int argsExpected): outInst:
L16
IASCORSA.invokeN(String meth, Object[] args, int argsExpected):
argsExpected: 1
IASCORSA.invokeN(String meth, Object[] args, int argsExpected): nbs.size
(): 26
IASCORSA.invokeN(String meth, Object[] args, int argsExpected):
nbs.getInternalB
uffer(): [B@1fae3c6
IASCORSA.invokeN(String meth, Object[] args, int argsExpected): meth:
GetObjectR
elationTypes
IASCORSA.invokeN(String meth, Object[] args, int argsExpected):
DispatchConstant
s.DISPATCH_METHOD: [DISPATCH_METHOD (1)]
IASCORSA.invokeN(String meth, Object[] args, int argsExpected): getPeer():
0
IASCORSA.invokeN(String meth, Object[] args, int argsExpected): getUnknown
(): 66
7380
IASCORSA.invokeN(String meth, Object[] args, int argsExpected): About to
call Ge
nericStub.dispatchInvoke
-----------------------------------------------------------
at com.oravision.corsa.IASCORSA.GetObjectRelationTypes(IASCORSA.java:331)
GenericStub.dispatchInvoke
method: GetObjectRelationTypes
peer: 0, unknown: 667380
instructions: v:V:L16
stackSize: 1
flags: [DISPATCH_METHOD (1)]
argStream: 32, argStreamSize: 26
08 20 14 00 00 00 00 00 . ......
00 00 00 00 00 00 00 00 ........
00 00 00 00 00 00 00 00 ........
00 00 00 00 00 00 00 00 ........
GenericStub.dispatchInvoke: about to call dispatchInvoke0
org.jawin.COMException: 80020005: Type mismatch.
at org.jawin.marshal.GenericStub.dispatchInvoke0(Native Method)
at org.jawin.marshal.GenericStub.dispatchInvoke
(GenericStub.java:202)
at org.jawin.DispatchPtr.invokeN(DispatchPtr.java:600)
at org.jawin.DispatchPtr.invokeN(DispatchPtr.java:556)
at com.oravision.corsa.IASCORSA.GetObjectRelationTypes
(IASCORSA.java:331
)
at com.oravision.corsa.test.Test.main(Test.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.simontuffs.onejar.Boot.run(Boot.java:247)
at com.simontuffs.onejar.Boot.main(Boot.java:105)
What are the possible causes for error?