In JVM COBOL, you use the CALL statement to interoperate with native code. For example:
call xxx using by yyy p by zzz q returning r
Where:
are the items between the using and returning key words. These are parameters. There can be zero or more parameters.
To call a native entry point in a shared library (.dll file on Windows or .so file on UNIX), you need to load the shared library to ensure that the JVM runtime system is aware of it. You must load the library before making the call to the native entry point.
01 my-dll procedure-pointer. set my-dll to entry "b" call "c"
program-id. b. display "IN B" end program b. program-id. c. display "INFO: in C" display "PASS" end program c.
This loads the native DLL (b.dll Windows) or CSO (b.so UNIX), making the programs it contains visible such that the CALL to program C succeeds.
The JVM run-time system attempts to resolve requested entry points to JVM methods that have the Callable attribute. If the entry point for a particular name is not found in JVM, the JVM run-time system attempts to resolve the entry point to a native entry point. If a native entry point is found, that entry point is called and that name is associated with the native entry point from then on, so that a full search is not done again.