public class Demo5 { /* Array size error */ public static int[] static5() { int i[] = {1,2,3,4,5,6}; return i; } }
javac Demo5.java
This produces a Demo5.class file in the current folder.
program-id. "demo5". working-storage section. 01 table5. 03 num5 pic x(4) comp-5 occurs 5. linkage section. procedure division. *> out of bounds Java will return an array larger than the COBOL size call "java.Demo5.static5" returning table5 on exception display "Exception occurred due to array mismatch" not on exception display "call successful" end-call. goback.
cob -x demo5.cbl
This produces the final COBOL executable file, demo1.
./demo5
The program should encounter an exception due a mismatch between table5 in the COBOL program and the i array in the static5 method, and output the following:
Exception occurred due to array mismatch
To process the not on exception phrase, change one of these elements to match the other, and then recompile.