This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Where to find a CNI-Tutorial?
Per Bothner writes:
> Andrew Haley wrote:
>
> > > 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.
>
> But if you have a C++ data structure that contains pointers, how
> do you get at this data structue from a Java object in the first
> place?
Well, you can put a C++ structure in a block of memory (an array of
jlongs, for example.) This has the property that the memory will be
reclaimed when it's no longer referenced.
But my main worry isn't how to store the pointer, but the fact that
all RawData pointers are the same type; you have even less type safety
than C++. I suppose if you have a rule that all access to RawData
must be private then this issue will rarely arise.
Andrew.