OaIdlUtil#toPrimitive fails to correctly calculate the raw index positions if the dimension bounds are not zero based.
This manifests when querying ranges from excel, which return 1-based arrays.
Provide complete information about the problem
- Version of JNA and related jars: Reproduced with JNA 4.4.0
- Version and vendor of the java virtual machine: Oracle 1.8.0_121; Java HotSpot(TM) 64-Bit Server VM 25.121-b13
- Operating system: Windows 10
- System architecture (CPU type, bitness of the JVM): AMD64, 64bit VM
- Complete description of the problem: See above
- Steps to reproduce: Both of these converts should work, the second fails with an ArrayIndexOutOfBoundsException
SAFEARRAY sa = SAFEARRAY.createSafeArray(new VARTYPE(VT_I4), 2, 2);
Object[][] data = (Object[][]) OaIdlUtil.toPrimitiveArray(sa, false);
for(Object[] row: data) {
System.out.println(Arrays.toString(row));
}
sa.rgsabound[0].lLbound = new LONG(1);
sa.rgsabound[1].lLbound = new LONG(1);
sa.write();
System.out.println(Arrays.toString((Object[]) OaIdlUtil.toPrimitiveArray(sa, false)));
OaIdlUtil#toPrimitive fails to correctly calculate the raw index positions if the dimension bounds are not zero based.
This manifests when querying ranges from excel, which return 1-based arrays.
Provide complete information about the problem