Skip to content

OaIdlUtil#toPrimitiveArray fails if dimension bounds are not 0-based #785

@matthiasblaesing

Description

@matthiasblaesing

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

  1. Version of JNA and related jars: Reproduced with JNA 4.4.0
  2. Version and vendor of the java virtual machine: Oracle 1.8.0_121; Java HotSpot(TM) 64-Bit Server VM 25.121-b13
  3. Operating system: Windows 10
  4. System architecture (CPU type, bitness of the JVM): AMD64, 64bit VM
  5. Complete description of the problem: See above
  6. 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)));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions