Skip to main content

[archive] Acu 7.1.3 calling Java

  • January 11, 2008
  • 3 replies
  • 0 views

[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.

3 replies

[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.
ecn3414 in version 8.0 corrected some problems when dealing with Java Arrays

For a mav it would be best to known what operating system you're working on.

[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.
ecn3414 in version 8.0 corrected some problems when dealing with Java Arrays

For a mav it would be best to known what operating system you're working on.

[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.
I was doing all testing on Windows XP, but we also need to use Solaris (haven't gotten around to trying that out yet).