You can call Java methods as static methods, virtual methods, or non-virtual methods by using op-codes 8-10 of the C$JAVA routine, or you can call a Java main method using op-code 29. If you do not use an op-code when you call C$JAVA, the default runtime behavior is to try to call the method statically, and then virtually by trying to create an object using a default constructor. A non-virtual method is called on the specific object that is being used. A virtual method can be called on a method that is inherited from one of the object's superclasses. Here are examples of each of the types of calls:
Default:
CALL "C$JAVA" USING "acuCobolGT/CAcuCobol", "CobolCallingJavaChar", "(C)C", FIELD-CHAR, FIELD-CHARRET GIVING STATUS-VAL.
Virtual:
CALL "C$JAVA" USING CJAVA-CALL, OBJECT-HANDLE, "acuCobolGT/CAcuCobol", "CobolCallingJavaLong", "(J)J", FIELD-LONG, FIELD-LONGRET GIVING STATUS-VAL.
Non-virtual:
CALL "C$JAVA" USING CJAVA-CALLNONVIRTUAL, OBJECT-HANDLE, "acuCobolGT/CAcuCobol", "CobolCallingJavaBoolean", "(Z)Z", FIELD-BOOL, FIELD-BOOLRET GIVING STATUS-VAL.
Static:
CALL "C$JAVA" USING CJAVA-CALLSTATIC, "acuCobolGT/CAcuCobol", "CobolCallingJavaDouble", "(D)D", FIELD-DOUBLE, FIELD-DOUBLERET GIVING STATUS-VAL.
Main:
CALL "C$JAVA" USING C JAVA-CALLJAVAMAIN, "CobolCallingJava", "StrParam1", "StrParam2", "StrParam3", "StrParam4" GIVING STATUS-VAL.
This example calls a Java main method with the following signature:
public static void main( String[] args );
Additional examples:
CALL "C$JAVA" USING CJAVA-CALLNONVIRTUAL, OBJECT-HANDLE, "acuCobolGT/CAcuCobol", "CobolCallingJavaVoid", "()V" GIVING STATUS-VAL. CALL "C$JAVA" USING CJAVA-CALL, OBJECT-HANDLE, "acuCobolGT/CAcuCobol", "CobolCallingJavaStringV", "(X)X", FIELD-STRING, FIELD-STRINGRET GIVING STATUS-VAL.