Implicit COBOL Table/Java Array Conversion

Restriction: Implicit conversion of string arrays is not supported; string arrays must be converted explicitly.

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:


In the above example, INT-GROUP is declared:

    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.