Array update semantics and restrictions in Java-interoperable applications
In Java™, arrays are always considered objects, even
when they are arrays of Java primitive types (such as
long), so when arrays are
passed between Java methods, changes made by a called method
are always reflected in the caller method, which is the normal behavior in Java for all object arguments.
java.lang.String objects or an array of
java.math.BigDecimal objects from Java, any changes to that data in COBOL will not be reflected on the Java side of the application. Similarly, when COBOL passes a table of
PIC X/N/U items to Java, any changes to that data in Java is not reflected on the COBOL side of the application.
At present, only fixed-length tables in COBOL can receive Java arrays (no ODO tables), and the number of elements in the incoming Java array and the number of elements in the COBOL table as indicated in its
OCCURS clause must match exactly. Otherwise, a Java exception of class
java.lang.IllegalArgumentException is thrown. This exception can be caught in Java code with try/catch and can be caught by a COBOL program calling a static Java method using the
ON EXCEPTION phrase of the