With ACUCOBOL-GT, you can also use C$JAVA op-codes to explicitly convert Java arrays to COBOL and COBOL tables to Java. This functionality gives you more precise control over the conversion process.
The op-code to convert a Java array to a table is JAVA-CONVERTARRAYTOTABLE. Here is an example of an array of Java ints being converted to a USAGE SIGNED-INT OCCURS 10 COBOL table:
CALL "C$JAVA" USING CJAVA-CONVERTARRAYTOTABLE, ARRAY_HANDLE, 10, 0, INT-TABLE(1) GIVING STATUS-VAL.
The call takes the array handle, the number of elements to convert, the starting element position in the array, and the COBOL table variable in which to place the converted array.
To explicitly convert a COBOL table to Java, you can use the C$JAVA op-code CJAVA-CONVERTTABLETOARRAY. Here is an example of a call that converts a table to an array:
CALL "C$JAVA" USING CJAVA-CONVERTTABLETOARRAY, INT-TABLE(1), 10, 0, ARRAY-HANDLE, GIVING STATUS-VAL.
In this case, the call requires the COBOL table from which the values are taken, the number of elements, the position of the first element, and the handle of the destination array.