This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
CNI and garbage collection
- To: java at gcc dot gnu dot org
- Subject: CNI and garbage collection
- From: mgd at swarm dot org (Marcus G. Daniels)
- Date: 19 Jul 2001 19:56:37 -0600
I've got a Java class from which I generate headers using gcjh. I'm
using the -prepend and -add features to insert declarations for ivars
types, and then the ivars themselves. In a CNI native method I have
some initialization code for setting up the C++ side of things. The
problem seems to be that garbage collection is moving my Java object,
but the ivars aren't following. I.e. if I disable garbage collection
the program runs fine.
In the CNI documentation,
http://gcc.gnu.org/java/papers/cni/t1308.html
it says that "The C++ compiler is smart enough to realize the class is
a Java class, and hence it needs to allocate memory from the garbage
collector."
But what about the C++ objects inside of the Java object? Is there a special
way to allocate them?