This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Where to find a CNI-Tutorial?
Jeff Sturm writes:
> On Mon, 25 Aug 2003, Clemens Eisserer wrote:
> > 1.) Does anybody know good tutorials for CNI?
> > The only tutorials I read where not really helpful, because they mostly
> > coverd how to access java from c, not how to access c from java.
>
> Native methods in CNI are C++, so they can call other C/C++ code. If
> you're accessing C code, the headers will have to be C++-safe.
>
> Post an example if you're stuck.
>
> > 2.) Is there a platform-independent way to store pointer-values in java
> > variables using CNI. With JNI this isnt possible as far as I know,
> > because storing pointer-values into "int" only works of cource on 32-bit
> > machines.
>
> That's what gnu.gcj.RawData is for.
Following my experience with SWT, I can only advise people not to do
this if at all possible. Better to do everything that requires
handling pointers in C++ and use a layer that isolates them in opaque
structures.
Andrew.