This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Finalization and CNI
- From: "Craig A. Vanderborgh" <craigv at voxware dot com>
- To: java at gcc dot gnu dot org
- Date: 10 Jun 2003 14:59:53 -0600
- Subject: Finalization and CNI
Hello All:
I am getting started with CNI programming and I have a question. I am a
seasoned JNI programmer getting into CNI for the first time and I have
some questions about memory management.
The main question is simply this - how does it work? Let's say, for
example, that I have the following CNI program:
HelloWorld.java:
class HelloWorld {
public native void print();
public static void main(String[] args) {
HelloWorld hw = new HelloWorld();
hw.print();
System.out.println("Hello World: DONE");
}
}
include <gcj/cni.h>
#include <stdio.h>
#include "HelloWorld.h"
void HelloWorld::print() {
printf("Hello, world from CNI!\n");
void *alloc = new char[1024];
}
Presumably "alloc" is going to be leaked, correct? Is the correct thing
to do to put the deallocation stuff into the destructor for the
HelloWorld class? Would my destructor then get called at some point?
Any words about how memory management works in the CNI world would be
greatly appreciated. Any pointers to docs, etc. would be nice also
because I have not been able to find much on this topic.
TIA
craig vanderborgh
voxware incorporated