Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot convert Variant to double[] #84

Open
dhiegorp opened this issue Aug 24, 2020 · 0 comments
Open

Cannot convert Variant to double[] #84

dhiegorp opened this issue Aug 24, 2020 · 0 comments

Comments

@dhiegorp
Copy link

I have an interface signature in a dll

[id(0x0000001d), propget, helpstring("property Contaminants")]
HRESULT Contaminants([out, retval] VARIANT* pVal);

Whose specification tells me that it returns an array of double of a fixed length and which I could attest to be correct via VBA code.
The generated java code for this method was:

@DISPID(29) //= 0x1d. The runtime will prefer the VTID if present
  @VTID(55)
  @ReturnValue(type=NativeType.VARIANT)
  Object contaminants();

The problem is that any calls to this method result in a null value.
I tried to map this in different ways, some resulting in conversion errors (exceptions), some of them resulting in JVM dump.
The best that I could do was "remap" the method to receive a Variant instance as argument:

  @DISPID(29) //= 0x1d. The runtime will prefer the VTID if present
  @VTID(55)
  @ReturnValue(type=NativeType.VARIANT)
  void  getContaminants(Variant variant);

Passing a brand new Variant to the method I could confirm that the variant instance was updated (its "image" buffer changed value). Calling getType() return me a Variant.Type.VT_ARRAY_R8, which was the expected (equivalent to a double[]) although, any attempts to return an Object or a double[] result in null values ( Variant#get, Variant#convertTo).

Someone had the same problem or have any clues to solve this?

I have to say that I'm using the COM4J zip package, which seems to be quite old concerning the commits to the master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant