[Migrated content. Thread originally posted on 09 January 2008]
We are experimenting with using Java as a bridge between Acu and other libraries that we are soon to be implementing. These are the problems I've encountered thus far when calling methods with an array as a paramater.1. Converting integer table to a java array (code straight from the acu sample code):
CALL "C$JAVA" USING CJAVA-CONVERTTABLETOARRAY,
INT-TABLE(1), 10, 1, ARRAY-HANDLE, GIVING STATUS-VAL.
Causes a memory access violation.
2. Passing through a table directly
01 INT-GROUP.
03 INT-DATA occurs 10 times.
05 INT-ELEMENT signed-int.
....
MOVE 91 TO INT-ELEMENT(1)
MOVE 92 TO INT-ELEMENT(2)
...
CALL "C$JAVA" USING CJAVA-CALLNONVIRTUAL, OBJECT-HANDLE,
CLASS-NAME, METHOD-NAME, "([I)I",
INT-GROUP, FIELD-INT-RET GIVING STATUS-VAL.
Works, but everything in the array is 0.
3. Calling a method that returns an array:
CALL "C$JAVA" USING CJAVA-CALLNONVIRTUAL, OBJECT-HANDLE,
CLASS-NAME, METHOD-NAME, "([I)[I",
INT-GROUP, INT-RET-GROUP GIVING STATUS-VAL.
After this call STATUS-VAL is zero, indicating it worked, but the logging within the method has not been executed, i.e. the method does NOT get called.
4. Calling a method with a multidimensional array as a paramater:
CALL "C$JAVA" USING CJAVA-CALLNONVIRTUAL, OBJECT-HANDLE,
CLASS-NAME, METHOD-NAME, "([[I)I",
INT-MULTI-GROUP, FIELD-INT-RET GIVING STATUS-VAL.
Gives a -4 error, method not found.
Incidently, using this:
CALL "C$JAVA" USING CJAVA-CREATEARRAY, CJAVA-INTARRAY,
ARRAY-SIZE GIVING ARRAY-HANDLE.
MOVE 1 to FIELD-INT.
CALL "C$JAVA" USING CJAVA-SETARRAYELEMENT, ARRAY-HANDLE, 1,
FIELD-INT, GIVING STATUS-VAL.
....
CALL "C$JAVA" USING CJAVA-CALLNONVIRTUAL, OBJECT-HANDLE,
CLASS-NAME, METHOD-NAME, "([I)I",
ARRAY-HANDLE, FIELD-INT-RET GIVING STATUS-VAL.
does work.
Does anyone know if these issues are fixed in a later version of Acu? Has anyone had any luck passing arrays to java methods?
Cheers,
Andy.



