Previous Topic Next topic Print topic


Pointers from Native Code to JVM COBOL

In theory, you can pass pointers from native code to managed code, but they have no meaning on the managed side, because if they were to be dereferenced they would give undefined results. This means you must not use data items defined as pointer in interoperation with native code.

To pass a pointer from native code to managed, you use an integer to hold the pointer. You must ensure that you allocate a storage item wide enough to store the pointer for the platform being used. We recommend using pic x for this purpose. For example:

    01 myPointer pic x(4).        *> on a 32-bit platform
    01 myPointer pic x(8).        *> on a 64-bit platform

On some platforms, the above example stores a pointer. So if we have an entry point 'getAPointer' which sets a reference to a pointer, you can call it as follows:

    call "getAPointer" using by reference myPointer

Equally, a pointer stored this way can be passed back to native code.

    call "setAPointer" using by reference myPointer

Note that callbacks are not supported in any form, since JVM COBOL entry point pointers have no meaning in native code

Previous Topic Next topic Print topic