Implicit COBOL Table/Java Array Conversion

With ACUCOBOL-GT, it is possible to pass a COBOL table directly to a method that requires a Java array. The contents of the table are automatically converted to an array of the type the Java method expects. When the method completes, the contents of the table are updated with what is in the array. You do not have to explicitly convert the COBOL table to a Java array and convert it back again. No special op-code is required to do the conversion. When the runtime sees the array type in the signature, it tries to convert that table parameter to an array. Here is an example of a table being passed to a Java method that takes an array parameter:

CALL "C$JAVA" USING CJAVA-CALL, OBJECT-HANDLE, "acuCobolGT/CAcuCobol", "CobolCallingJavaIntArray", "([I)I", INT-GROUP, FIELD-RET GIVING STATUS-VAL.

In the above example, INT-GROUP is declared:

01 INT-GROUP.
    03  INT-DATA occurs 10 times.
        05  INT-ELEMENT signed-int.

The values for INT-GROUP are set as follows:

    MOVE 1111 to INT-ELEMENT(1)
    MOVE 2222 to INT-ELEMENT(2)
    MOVE 3333 to INT-ELEMENT(3)
    MOVE 4444 to INT-ELEMENT(4)
    MOVE 5555 to INT-ELEMENT(5)

It should be noted that the type of the table passed into the Java method should be the appropriate type, that is, data of the same element size (in bits). The size of the Java array will be the number of elements in the table.