Re: Problems with Variant serialization

Morten Andersen <[email protected]>
Newsgroups gmane.comp.windows.devel.jawin
Organization Arosii Information Systems A/S
Message-ID <[email protected]>
Hi Andrzej

First sorry for being so slow in answering this, been a bit busy.

Andrzej Bialecki wrote:

>
> I noticed, however, that the result I'm getting is a Byte[], where the
> original Variant is supposed to contain byte[]. I'm wondering if I
> shouldn't get a byte[] as well? I'm slightly concerned about the memory
> footprint of objects vs. primitive types, for large arrays...

I understand why you are concerned about this. Is it correct that the
returned array are of type: "VT_ARRAY | VT_UI1 | VT_VARIANT"?

If this is the case I suggest you try to do the following in
org.jawin.Variant:

In the method:
   private static Object readObject(short vt, LittleEndianInputStream
leis) throws COMException, IOException {

Move the two starting "if's", that is:
   if (0 != (vt & VarTypes.VT_ARRAY)) {
     return readArray((short) (vt & VarTypes.VT_TYPEMASK), leis);
   }

   if (0 != (vt & VarTypes.VT_BYREF)) {
     return readObject((short) (vt & VarTypes.VT_TYPEMASK), leis);
   }

to the bottom of the method, and outcomment the "default" in the case
above this, that is the line:
   throw new COMException("Unable to deserialize variant type: " + vt);

Please let me know if this solves your problem? Then I will check in
this change (sorry for using you for fixing this, but I don't have time
right now to write a testcase, and test it locally).

Best Regards
Morten
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.