Created On: 19 May 2010
Problem:
There exists documentation that shows how to pass an argument in a C$JAVA CALL, but it's not easy to understand the correct syntax when more arguments are involved.
Resolution:
This article explains how to pass more than one single argument in a C$JAVA CALL, when a COBOL program interhoperates with a JAVA class. You can pass as many arguments as the method requires. You will need to specify the correct method signature, which you can obtain using the Java class dissassembler utility "javap":
$ javap -s myclass
Let's say you've got a method that takes two Strings and three numbers as arguments, and returns an integer.
The signature would be "(Ljava/lang/String;Ljava/lang/String;III)I" (this will be returned by javap).
CALL "C$JAVA" USING CJAVA-CALL,
OBJECT-HANDLE,
"someMethod",
"(Ljava/lang/String;Ljava/lang/String;III)I"
INPUT-STRING-1
INPUT-STRING-2
INPUT-NUMBER-1
INPUT-NUMBER-2
INPUT-NUMBER-3
OUTPUT-NUMBER
GIVING STATUS-VAL
END-CALL.
$ javap -s myclass
Let's say you've got a method that takes two Strings and three numbers as arguments, and returns an integer.
The signature would be "(Ljava/lang/String;Ljava/lang/String;III)I" (this will be returned by javap).
CALL "C$JAVA" USING CJAVA-CALL,
OBJECT-HANDLE,
"someMethod",
"(Ljava/lang/String;Ljava/lang/String;III)I"
INPUT-STRING-1
INPUT-STRING-2
INPUT-NUMBER-1
INPUT-NUMBER-2
INPUT-NUMBER-3
OUTPUT-NUMBER
GIVING STATUS-VAL
END-CALL.
Incident #2453212
Old KB# 31405



