I have an idl file that defines a char[] in a struct as follows:
struct baseDataHdr_S {
octet paramId[16];
short miscHdrBytes;
};
The autogenerated Java code looks correct, but when sending the Topic I get an error:
java.lang.ArrayIndexOutOfBoundsException: 8
at ...baseDataHdr_STypeSupport.serialize
Looking in the java code the char[] is correctly defined as a char[16], so I'm stumped why indexing char[8] during serialization would cause this exception.
If the char that you are stuffing into the octet array are two-byte char, it will oob around 8.
Just a thought. Are these ASCII or UTF-8 or Unicode or ... characters?
The (rtiddsgen) created class def has a member defined like so:
public byte [] paramId= new byte [16];
And the corresponding TypeSupport class has this block that is throwing the exception in the for loop when i1__ == 8
baseDataHdr_S typedSrc = (baseDataHdr_S) src;
for(int i1__ = 0; i1__< 16; ++i1__){
dst.writeByte(typedSrc.paramId[i1__]);
}
Given just these two sections of code, I dont see an issue. The troubling thing is that this is all happening in the autogenerated Java code. I couldn't change it if I wanted to.
Is there any kind of byte alignment going on behind the sceens?