Is cast (NonJavaObject*) to (long) legal for cni callback purposes?

Tom Tromey tromey@redhat.com
Fri Jun 23 17:54:00 GMT 2006


>>>>> "Olivier" == Olivier de Mirleau <odmi@imc.nl> writes:

Olivier> Hi, I'm currently using a procedure described below to do c2j2c
Olivier> callbacks with cni.
Olivier> It seems to work for now, but I'm not quite sure it's supposed to
Olivier> ALWAYS work.

Olivier> 1. I cast the pointer to the NonJavaClass instance to a long and pass
Olivier>    that as a jlong to java.

With gcj (and CNI) you can also use the 'RawData' class for this
purpose.  There's a section in the gcj manual about this.  Basically
RawData is handled specially by the compiler and the runtime and is
kind of like 'void*'.

One slight advantage of this over using jlong is that you may
(depending on packing) get a space savings on 32 bit systems.

Tom



More information about the Java mailing list